{"thread":{"id":"8299","subject":"Make \"git gc\" pack all refs by default","startedAt":"2007-05-24T18:41:39Z","lastAt":"2007-05-25T02:20:48Z","messageCount":4,"participants":["Linus Torvalds","Johannes Schindelin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"43164","messageId":"alpine.LFD.0.98.0705241132400.26602@woody.linux-foundation.org","threadId":"8299","inReplyTo":null,"subject":"Make \"git gc\" pack all refs by default","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-05-24T18:41:39Z","receivedAt":"2007-05-24T18:41:39Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nI've taught myself to use \"git gc\" instead of doing the repack explicitly, \nbut it doesn't actually do what I think it should do.\n\nWe've had packed refs for a long time now, and I think it just makes sense \nto pack normal branches too. So I end up having to do\n\n\tgit pack-refs --all --prune\n\nin order to get a nice git repo that doesn't have any unnecessary files.\n\nSo why not just do that in \"git gc\"? It's not as if there really is any \ndownside to packing branches, even if they end up changing later. Quite \noften they don't, and even if they do, so what?\n\nAlso, make the default for refs packing just be an unambiguous \"do it\", \nrather than \"do it by default only for non-bare repositories\". If you want \nthat behaviour, you can always just add a\n\n\t[gc]\n\t\tpackrefs = notbare\n\nin your ~/.gitconfig file, but I don't actually see why bare would be any \ndifferent (except for the broken reason that http-fetching used to be \ntotally broken, and not doing it just meant that it didn't even get \nfixed in a timely manner!).\n\nSo here's a trivial patch to make \"git gc\" do a better job. Hmm?\n\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>\n---\n\nSide note: I'd also like to get rid of \"info/refs\", and just make http \nfetching use \"packed-refs\" instead. That would imply that \n\"update_server_info()\" should do \"git pack-refs --all\" too! This patch \ndoesn't do it, though.\n\n builtin-gc.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex 8ea165a..45025fb 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -17,11 +17,11 @@\n \n static const char builtin_gc_usage[] = \"git-gc [--prune] [--aggressive]\";\n \n-static int pack_refs = -1;\n+static int pack_refs = 1;\n static int aggressive_window = -1;\n \n #define MAX_ADD 10\n-static const char *argv_pack_refs[] = {\"pack-refs\", \"--prune\", NULL};\n+static const char *argv_pack_refs[] = {\"pack-refs\", \"--all\", \"--prune\", NULL};\n static const char *argv_reflog[] = {\"reflog\", \"expire\", \"--all\", NULL};\n static const char *argv_repack[MAX_ADD] = {\"repack\", \"-a\", \"-d\", \"-l\", NULL};\n static const char *argv_prune[] = {\"prune\", NULL};\n"},{"id":"43172","messageId":"Pine.LNX.4.64.0705242027430.4648@racer.site","threadId":"8299","inReplyTo":"alpine.LFD.0.98.0705241132400.26602@woody.linux-foundation.org","subject":"Re: Make \"git gc\" pack all refs by default","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-05-24T19:28:41Z","receivedAt":"2007-05-24T19:28:41Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 24 May 2007, Linus Torvalds wrote:\n\n> I've taught myself to use \"git gc\" instead of doing the repack explicitly, \n> but it doesn't actually do what I think it should do.\n> \n> We've had packed refs for a long time now, and I think it just makes sense \n> to pack normal branches too.\n\nFWIW I already suggested that: \nhttp://article.gmane.org/gmane.comp.version-control.git/28533\n\nSince there seemed not much interest in that, I let it slip.\n\nCiao,\nDscho\n"},{"id":"43204","messageId":"7vy7jdu08k.fsf@assigned-by-dhcp.cox.net","threadId":"8299","inReplyTo":"alpine.LFD.0.98.0705241132400.26602@woody.linux-foundation.org","subject":"Re: Make \"git gc\" pack all refs by default","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-25T02:04:59Z","receivedAt":"2007-05-25T02:04:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> Also, make the default for refs packing just be an unambiguous \"do it\", \n> rather than \"do it by default only for non-bare repositories\". If you want \n> that behaviour, you can always just add a\n>\n> \t[gc]\n> \t\tpackrefs = notbare\n>\n> in your ~/.gitconfig file, but I don't actually see why bare would be any \n> different (except for the broken reason that http-fetching used to be \n> totally broken, and not doing it just meant that it didn't even get \n> fixed in a timely manner!).\n\nBoy, you are a lot more aggressive than me.\n\nBut the fix was in v1.5.0 and we had two feature releases since\nthen, so it's a good time to do this.  Thanks.\n"},{"id":"43209","messageId":"alpine.LFD.0.98.0705241911200.26602@woody.linux-foundation.org","threadId":"8299","inReplyTo":"7vy7jdu08k.fsf@assigned-by-dhcp.cox.net","subject":"Re: Make \"git gc\" pack all refs by default","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-05-25T02:20:48Z","receivedAt":"2007-05-25T02:20:48Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 24 May 2007, Junio C Hamano wrote:\n> \n> Boy, you are a lot more aggressive than me.\n\nHeh. \n\nI don't like the http interfaces, so I have a much easier time saying \n\"they were broken, deal with it\" ;)\n\nI also think that we mis-calculated earlier in assuming that prople don't \nhave lots of branches, and that packing branches was thus much less \nimportant than packing tags.\n\nIt's true that in sane git-only environment, you don't have lots of \nbranches (fifty isn't \"lots\"). But when importing things from other \nenvironments, I seem to recall people talking about thousands of branches \n(since they cannot be merged and they are project-wide rather than some \nlocal entity, they cannot disappear).\n\nSo I think it's better to just pack branches aggressively too, and in \nfact, once you do that, and http-fetch knows about it, then that also \nmeans that info/refs becomes pointless, because afaik, it doesn't actually \ncontain anything more than what a modern \"packed-refs\" file contains.\n\nSo in order to take that _next_ step, we need to encourage people to pack \nbranches, and then at some point we can hopefully just make http-fetch \nstart ignoring info/refs..\n\nSo yeah, I think being aggressive here is a good idea. I really also \nwanted to make update-server-info do the pack-refs thing, but to do it \nproperly we'd need to make the whole pack-refs thing have a nice library \ninterface, so it was a much bigger (although probably fairly \nstraightforward) thing.\n\n\t\tLinus\n"}]}