threads / discuss / 21331

Detached HEAD and "git log --all"

Subject: Detached HEAD and "git log --all"

## tl;dr

3 messages between Oct 22, 2009 and Oct 23, 2009.

replies: 2people: 2as markdown or json

Jakub Narebski· Oct 22, 2009, 20:37 UTC · lore

When discussing differences between concept and implementation of branches in Git and in Mercurial on StackOverflow[1] (abusing SO comment system a bit), Steve Losh[2] wrote that he was surprised by the fact that "git log --all" doesn't include commits made on detached HEAD.

While documentation clearly states:
  --all  Pretend as if all the refs in `$GIT_DIR/refs/` are listed
         on the command line as <commit>.

and HEAD is in `$GIT_DIR/HEAD`, which is outside `$GIT_DIR/refs/`, it is nevertheless a bit strange that "git log --all" doesn't list all (everything).

This is of course only an issue if we are on detached HEAD; I guess that semantics of `--all` option to git-log predates this feature.

[1] http://stackoverflow.com/questions/1598759/git-and-mercurial-compare-and-contrast/1599930#1599930 [2] http://stevelosh.com/blog/entry/2009/8/30/a-guide-to-branching-in-mercurial/

-- 
Jakub Narębski      http://stackoverflow.com/users/46058/jakub-narebski
Michael J Gruber· Oct 23, 2009, 08:33 UTC · re: Jakub Narebski · lore

Re: Detached HEAD and "git log --all"

Jakub Narebski venit, vidit, dixit 22.10.2009 22:37:
Show 21 quoted lines
> When discussing differences between concept and implementation
> of branches in Git and in Mercurial on StackOverflow[1] (abusing
> SO comment system a bit), Steve Losh[2] wrote that he was surprised
> by the fact that "git log --all" doesn't include commits made
> on detached HEAD.
> 
> While documentation clearly states:
> 
>   --all  Pretend as if all the refs in `$GIT_DIR/refs/` are listed
>          on the command line as <commit>.
> 
> and HEAD is in `$GIT_DIR/HEAD`, which is outside `$GIT_DIR/refs/`,
> it is nevertheless a bit strange that "git log --all" doesn't list
> all (everything).
> 
> This is of course only an issue if we are on detached HEAD; I guess
> that semantics of `--all` option to git-log predates this feature.
> 
> [1] http://stackoverflow.com/questions/1598759/git-and-mercurial-compare-and-contrast/1599930#1599930
> [2] http://stevelosh.com/blog/entry/2009/8/30/a-guide-to-branching-in-mercurial/
> 

Commit 77abcbd (Let --decorate show HEAD position, 2009-10-12) goes a little bit in that direction, adding HEAD to the "labels" that --decorate may use, but not to the list of refs specified by "--all". But:

Well, after playing around a bit: git rev-list --all does list my detached HEAD, git log --all shows it (which is the same statement, of course), whether I use --decorate or not. Are you seeing different behaviour?

git describe --all HEAD does not describe the detached HEAD (other than v1.6.5-87-g4584daf in my case), which may or may not be desirable (because describe outputs at most one description, unlike --decorate).

Michael
Michael J Gruber· Oct 23, 2009, 08:36 UTC · re: Jakub Narebski · lore

Re: Detached HEAD and "git log --all"

Jakub Narebski venit, vidit, dixit 22.10.2009 22:37:
Show 21 quoted lines
> When discussing differences between concept and implementation
> of branches in Git and in Mercurial on StackOverflow[1] (abusing
> SO comment system a bit), Steve Losh[2] wrote that he was surprised
> by the fact that "git log --all" doesn't include commits made
> on detached HEAD.
> 
> While documentation clearly states:
> 
>   --all  Pretend as if all the refs in `$GIT_DIR/refs/` are listed
>          on the command line as <commit>.
> 
> and HEAD is in `$GIT_DIR/HEAD`, which is outside `$GIT_DIR/refs/`,
> it is nevertheless a bit strange that "git log --all" doesn't list
> all (everything).
> 
> This is of course only an issue if we are on detached HEAD; I guess
> that semantics of `--all` option to git-log predates this feature.
> 
> [1] http://stackoverflow.com/questions/1598759/git-and-mercurial-compare-and-contrast/1599930#1599930
> [2] http://stevelosh.com/blog/entry/2009/8/30/a-guide-to-branching-in-mercurial/
> 

...OK, finally found it: Dscho did just that in f0298cf (revision walker: include a detached HEAD in --all, 2009-01-16) which is in v1.6.1.3 and later.

Cheers, Michael

← back to recent threads