aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/wf.py
diff options
context:
space:
mode:
Diffstat (limited to 'wf.py')
-rwxr-xr-xwf.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/wf.py b/wf.py
index 7b5ae12..dda4914 100755
--- a/wf.py
+++ b/wf.py
@@ -1231,7 +1231,7 @@ def cmd_merge(args) -> int:
bmain = config.git_top(cfg.root) or main # books repo: the private repo of a split project, else main
private = [str(Path(x).resolve().relative_to(bmain.resolve())) for x in getattr(args, "private", None) or []]
files = [str(f.relative_to(bmain)) for f in (cfg.tasks, cfg.archive)] + private
- if git_run(top, "status", "--porcelain", "-uall").stdout.strip():
+ if _dirty_outside(top, []):
raise Failure("worktree has uncommitted changes: commit them first")
had = unmerged_count(top, master)
if not branch and not had:
@@ -1326,6 +1326,8 @@ def _dirty_outside(top: Path, keep: list[Path]) -> list[str]:
for line in git_run(top, "status", "--porcelain", "-uall").stdout.splitlines():
rel = line[3:].split(" -> ")[-1].strip('"').rstrip("/")
path = (top / rel).resolve()
+ if rel == config.WF_HOME: # wf start's pointer in a code worktree, never committed
+ continue
if not any(path == k or k in path.parents for k in keep):
stray.append(rel)
return stray
@@ -1531,6 +1533,12 @@ def cmd_start(args) -> int:
git_ok(repo, "worktree", "add", "-q", str(wt), "-b", b, master)
how = f"new, branch {b} from {master}"
else:
+ own = git_run(wt, "rev-parse", "--path-format=absolute", "--git-common-dir").stdout.strip()
+ want = git_run(repo, "rev-parse", "--path-format=absolute", "--git-common-dir").stdout.strip()
+ if not own or Path(own).resolve() != Path(want).resolve():
+ raise Failure(f"{shown} is not a worktree of {repo}"
+ + (f" (it belongs to {Path(own).resolve().parent})" if own else "")
+ + f": pass a worktree path of {repo} (e.g. {repo}/.worktrees/<lane>)")
dirty = git_run(wt, "status", "--porcelain").stdout.rstrip("\n")
cur = config.git_branch(Path(git_run(wt, "rev-parse", "--absolute-git-dir").stdout.strip()))
if dirty and not args.recovery: