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

Re: [RFC] git-pack-refs --prune

From
Junio C Hamano <junkio@cox.net>
Date
Sep 18, 2006, 18:44 UTC
Message-ID
<7vhcz5ow0a.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0609180934360.4388@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 11 quoted lines
> The way to fix both these problems at once would be to add a flag to the 
> "for_each_ref()", which says whether it followed a link, or whether it was 
> already packed, so that we wouldn't pack symlinks at all, and we wouldn't 
> add already-packed refs to the "keeprefs" list.
>
> But that requires a sligh semantic extension to "do_for_each_ref()" (and 
> "struct ref_list" needs a flag to say whether it was looked up through a 
> symlink).
>
> I was thinking that the easy way to solve it is to just _pack_ everything 
> (the way we do now - incorrectly for symrefs), but never prune a symref.

I see. Thanks for pointing out the issue with symrefs. I think clone with --use-separate-remote creates remote/$that_repo/HEAD that points at the branch the remote side's HEAD points at (to be precise, the one it guessed the remote side's HEAD points at), so this is a real issue already.

I wanted to update for_each_ref() anyway for other reasons (it really should take callback data -- the way the current users use global variables to work this around is eyesore), so hopefully I'll find time to take a look at it.

Rough outline:
 - for_each_ref() and friends become:
   typedef int each_ref_fn(const char *refname,
			   const unsigned char *sha1,
   #define REF_IS_SYMREF 01
   #define REF_IS_PACKED 02
                           int flags, /* above bits or'ed */ 
                           void *cb_data);
   int for_each_ref(each_ref_fn fn, void *cb_data);
 - handle_one_ref notices a symref and ignores it; it remembers
   refs that are not symref and are still loose for later
   pruning under --prune.

We might want to update the initial handshake of upload-pack protocol so that peek-remote and fetch-pack can tell which one is a symref pointing at what. Do the usual server_capabilities discovery in connect.c::get_remote_heads(), and if an extension "symref" is supported than ask for symref information (typically we would only get "HEAD points at refs/heads/foo" and nothing else). Then git-clone.sh does not have to make a guess. But that is a separate topic.

 
Previous: Linus TorvaldsNext: Junio C Hamano
Message 13 of 21 in “Allow multiple "git_path()" uses”
  1. Linus TorvaldsSep 11, 2006
  2. Start handling references internally as a sorted in-memory listLinus Torvalds, Sep 11, 2006
  3. Linus TorvaldsSep 11, 2006
  4. Junio C HamanoSep 11, 2006
  5. Linus TorvaldsSep 12, 2006
  6. Chris WedgwoodSep 12, 2006
  7. Add support for negative refsLinus Torvalds, Sep 12, 2006
  8. Make ref resolution sanerLinus Torvalds, Sep 12, 2006
  9. Jeff KingSep 12, 2006
  10. Linus TorvaldsSep 12, 2006
  11. [RFC] git-pack-refs --pruneJunio C Hamano, Sep 18, 2006
  12. Linus TorvaldsSep 18, 2006
  13. Junio C HamanoSep 18, 2006
  14. Junio C HamanoSep 21, 2006
  15. 1/5 symbolit-ref: fix resolve_ref conversion.Junio C Hamano, Sep 21, 2006
  16. 2/5 Add callback data to for_each_ref() family.Junio C Hamano, Sep 21, 2006
  17. 3/5 Tell between packed, unpacked and symbolic refs.Junio C Hamano, Sep 21, 2006
  18. 4/5 pack-refs: do not pack symbolic refs.Junio C Hamano, Sep 21, 2006
  19. 5/5 git-pack-refs --pruneJunio C Hamano, Sep 21, 2006
  20. Linus TorvaldsSep 21, 2006
  21. Junio C HamanoSep 22, 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.