git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git rev-list --all --reflog does not include worktree references
@ 2015-10-05 19:08 Andreas Schwab
  2015-10-06  9:39 ` Michael J Gruber
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2015-10-05 19:08 UTC (permalink / raw)
  To: git

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.

$ 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.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git rev-list --all --reflog does not include worktree references
  2015-10-05 19:08 git rev-list --all --reflog does not include worktree references Andreas Schwab
@ 2015-10-06  9:39 ` Michael J Gruber
  0 siblings, 0 replies; 2+ messages in thread
From: Michael J Gruber @ 2015-10-06  9:39 UTC (permalink / raw)
  To: Andreas Schwab, git

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.

> $ 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-06  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-05 19:08 git rev-list --all --reflog does not include worktree references Andreas Schwab
2015-10-06  9:39 ` Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).