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

Re: (unknown)

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 26, 2006, 15:35 UTC
Message-ID
<Pine.LNX.4.64.0610260825040.3962@g5.osdl.org>
In-Reply-To
<200610261522.44433.Josef.Weidendorfer@gmx.de>
On Thu, 26 Oct 2006, Josef Weidendorfer wrote:
Show 8 quoted lines
> On Thursday 26 October 2006 00:20, Junio C Hamano wrote:
> > Heh, I spoke too fast.
> > 
> > 	"git log origin..master"
> > 
> > If you do not have none of .git/origin
> 
> Really? I thought refs are always looked up in ".git/refs" only?
Yes and no.

The "iterate over all refs" code only ever looks in the "refs" subdirectory, so when you _list_ refs, they won't ever be shown unless they are there. That affects a lot of programs (like "git ls-remote").

Also, a symlink-ref has to point into "refs/" or it is considered invalid.
But, there are two extra rules:
 - ".git/HEAD" is obviously special, and will show up separately even for 
   things like "git ls-remote", so even processes that _list_ things will 
   show it.
 - when you do a named lookup, stuff directly in ".git" will take 
   precedence over EVERYTHING, even if it is never listed. So for example, 
   if you have a branch named HEAD in .git/refs/heads/HEAD, it doesn't 
   matter. Your ".git/HEAD" will still be looked up first.
   Similarly, other "special heads", like ORIG_HEAD or MERGE_HEAD will be 
   looked up in .git, even though they will never be listed by anything.

So the "refs/" requirement is a real requirement for a "true ref", but it is still overruled by the rule that we have special refs in $GIT_DIR that always take precedence.

This also means, for example, that you can always give the "full" refname for lookup, ie

	git-rev-parse refs/heads/master

works, because that's the "full path" from the ".git" subdirectory. If we only ever looked things up inside "refs", you'd have to use "heads/master".

Previous: Josef WeidendorferNext: Shawn Pearce
Message 13 of 14 in “(unknown)”
  1. andyparkins@gmail.comOct 25, 2006
  2. Jakub NarebskiOct 25, 2006
  3. Andy ParkinsOct 25, 2006
  4. Karl HasselströmOct 25, 2006
  5. Junio C HamanoOct 25, 2006
  6. Andy ParkinsOct 25, 2006
  7. Junio C HamanoOct 25, 2006
  8. Junio C HamanoOct 25, 2006
  9. Andy ParkinsOct 26, 2006
  10. Documentation: clarify refname disambiguation rules.Junio C Hamano, Oct 26, 2006
  11. Jakub NarebskiOct 26, 2006
  12. Josef WeidendorferOct 26, 2006
  13. Linus TorvaldsOct 26, 2006
  14. Shawn PearceOct 25, 2006

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.