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

Re: [RFC][PATCH] for_each_ref() returning heads in wrong order

From
Junio C Hamano <junkio@cox.net>
Date
Sep 23, 2006, 19:31 UTC
Message-ID
<7vu02ys7kg.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060923160712.5890.73139.stgit@machine.or.cz>
Petr Baudis <pasky@suse.cz> writes:
Show 6 quoted lines
> Using the #next branch I've now hit a problem with git-fetch-pack
> master choosing refs/bases/master (I geuss created by StGIT) instead
> of refs/heads/master. The old upload-pack returned the refs in the order
> heads-tags-everything_else but the new one just goes for whatever order
> readdir() returns them in (modulo merging with packed refs). I actually
> can't see the difference that caused this right now, though.

I think it is the other way around (the new one sorts, the old one doesn't). fetch-pack lets for_each_ref() to pick, but the wrapper git-fetch I think prepends refs/ and refs/heads as needed, so if you explicitly say heads/master I do not think you have a problem.

However, I see a bit bigger problem here. I think rev-parse would not complain "master" is ambiguous in your repository, because it has a fixed list of prefixes ("", refs, refs/tags, refs/heads, refs/remotes, refs/remotes/%/HEAD) it uses to DWIM in sha1_file.c::get_sha1_basic(), and refs/bases is not part of the prefixes.

I suspect we should fix connect.c::count_refspec_match(), which currently is just a strict tail match, to use the same list of prefix.

Previous: Linus Torvalds
Message 6 of 6 in “for_each_ref() returning heads in wrong order”
  1. Petr BaudisSep 23, 2006
  2. Petr BaudisSep 23, 2006
  3. Johannes SchindelinSep 23, 2006
  4. Petr BaudisSep 23, 2006
  5. Linus TorvaldsSep 23, 2006
  6. Junio C HamanoSep 23, 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.