Subject: bug#79024: 31.0.50; Multiple working trees support for VC

From: Eli Zaretskii <[email-masked]>
Date: Sun, 10 Aug 2025 13:50:07 +0300

> From: Sean Whitton <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Mon, 28 Jul 2025 20:55:32 +0100
> 
> > Please show the Git commands we issue during this test, and I will try
> > running them from the shell to see what's going on and why.
> 
> Okay, based on adding some tracing to vc-git-command and vc-git--call,
> and inserting 'mv' and 'cd' commands to correspond to other things the
> test does, this is what I have for you:

See the results below, sorry for a long delay.  Where I show nothing
after a command it means the command seemed to have succeeded.

> mkdir first
> cd first
> git init
> # create 'foo'
> git --no-pager ls-files -c -z -- foo
> git --no-pager ls-tree --name-only -z HEAD -- foo

This fails:

  fatal: Not a valid object name HEAD

> git update-index --add -- foo
> git --no-pager ls-files -c -z -- foo
> git --no-pager status --porcelain -z --untracked-files --ignored -- foo
> git --no-pager rev-parse HEAD

This also fails:

  HEAD
  fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

> git --no-pager symbolic-ref HEAD
> git commit -F c:/Users/... --only -- foo # make a commit msg temp file
> git --no-pager rev-parse HEAD
> git for-each-ref --format=%(refname) -- nil

This fails:

  bash: syntax error near unexpected token `('

> git worktree add --detach ../second/
> git worktree prune
> git worktree list --porcelain -z

This fails:

  error: unknown switch `z'
  usage: git worktree add [<options>] <path> [<branch>]
     or: git worktree list [<options>]
     or: git worktree lock [<options>] <path>
     or: git worktree prune [<options>]
     or: git worktree unlock <path>

      --porcelain           machine-readable output

(All the other "list --porcelain -z" commands fail as well.  They do
succeed if used without -z.)

> cd ../second
> git worktree prune
> git worktree list --porcelain -z
> cd ../first
> mv ../second ../third
> git worktree repair

This fails:

  fatal: Not a git repository: D:/gnu/git/first/.git/worktrees/second

> git worktree prune

Likewise.

> git worktree list --porcelain -z

Likewise.

> cd ../third
> mv ../first ../second
> git worktree repair

Likewise.

> git worktree prune

Likewise.

> git worktree list --porcelain -z

Likewise.

> mv ../second ../first
> git worktree repair

Fails:

  fatal: Not a git repository: D:/gnu/git/first/.git/worktrees/second

> cd ../first
> git update-index --refresh
> git --no-pager rev-parse --verify HEAD
> git diff-index --relative -z -M HEAD --
> git ls-files -z -d --
> git ls-files -z -u --
> git ls-files -z -o --exclude-standard --
> git worktree remove -f ../third/

This fails:

  usage: git worktree add [<options>] <path> [<branch>]
     or: git worktree list [<options>]
     or: git worktree lock [<options>] <path>
     or: git worktree prune [<options>]
     or: git worktree unlock <path>

Does this provide useful info about the failure reason(s)?