git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git rev-list --all --reflog does not include worktree references

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Oct 6, 2015, 09:39 UTC
Message-ID
<561396BD.9030205@drmicha.warpmail.net>
In-Reply-To
<87io6l16cc.fsf@igel.home>
Andreas Schwab venit, vidit, dixit 05.10.2015 21:08:
> When running git rev-list --all --reflog in the main worktree it doesn't
> include commits only referenced by the worktrees, neither HEAD nor its
> reflog.

HEAD is per worktree, so other worktrees' HEADs should not be included in "--all", I would think.

Show 21 quoted lines
> $ git init test
> $ cd test
> # add some commits
> $ touch 1; git add 1; git commit -m 1
> $ touch 2; git add 2; git commit -m 2
> # add new worktree
> $ git worktree add ../test2 master^{}
> $ cd ../test2
> # add more commits
> $ touch 3; git add 3; git commit -m 3
> $ touch 4; git add 4; git commit -m 4
> # create an unreferenced commit
> $ git checkout @^
> # both commands should give the same number of commits
> $ git rev-list --reflog | wc -l
> 4
> $ git -C ../test rev-list --all --reflog | wc -l
> 2
> 
> IIUC this will cause git gc to prune references from worktrees too
> early.

Since HEAD is per worktree, its reflog is so, too. So I think that "git rev-list" is actually right.

What's worrysome is that running "git prune -n" gives different results, depending on whether you run it in the main worktree or the new worktree.

In fact, running "git prune" in the main worktree followed by "git reflog" in the new worktree results in

fatal: bad object HEAD

So, "rev-list" should learn something like "--reflogs" or (better) "--worktrees" to make it look at worktree specific refs, too, and prune should use that, of course. "prune" does know about worktrees, but I guess it looks at HEADs only, not their reflogs.

Michael
Previous: Andreas Schwab
Message 2 of 2 in “git rev-list --all --reflog does not include worktree references”
  1. Andreas SchwabOct 5, 2015
  2. Michael J GruberOct 6, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.