{"thread":{"id":"11195","subject":"Removing redundant packs","startedAt":"2007-12-08T12:50:50Z","lastAt":"2007-12-08T23:50:32Z","messageCount":4,"participants":["Petr Baudis","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"62413","messageId":"20071208125050.GA17478@machine.or.cz","threadId":"11195","inReplyTo":null,"subject":"Removing redundant packs","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2007-12-08T12:50:50Z","receivedAt":"2007-12-08T12:50:50Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\n  before exporting whole repo.or.cz over rsync for mirroring, I would\nlike to clean up the worst repositories (esp. linux-2.6 repositories)\nwhose objects database looks absolutely horrible now.\n\n  At the same time, I have to be careful not to prune all unreferenced\nobjects since they can be referenced in forks.\n\n  How would you go about it? My idea was to do a fresh cummulative pack\nof all referenced objects with\n\n\tgit repack -a\n\nand then remove packs that contain _only_ objects that are already in\nthe fresh pack. But I have trouble with the second step; a very naive\ngrep loop ran for about a day when I stopped it and it was nowhere near\nthe half of the packs yet. I didn't figure out how to make use of\ngit-pack-redundant either.\n\n  Does anyone have any hints?\n\n  Thanks!\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nWe don't know who it was that discovered water, but we're pretty sure\nthat it wasn't a fish.\t\t-- Marshall McLuhan\n"},{"id":"62433","messageId":"7vsl2cvpef.fsf@gitster.siamese.dyndns.org","threadId":"11195","inReplyTo":"20071208125050.GA17478@machine.or.cz","subject":"Re: Removing redundant packs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-08T21:37:44Z","receivedAt":"2007-12-08T21:37:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@ucw.cz> writes:\n\n> At the same time, I have to be careful not to prune all unreferenced\n> objects since they can be referenced in forks.\n\nHow about...\n\n (1) In each repository, run \"repack -a -d\".  That would ensure that\n     everybody has the necessary objects that they themselves need.  By\n     doing this for a repository that borrows from another makes sure\n     pruning the latter would not break the former, so you start from\n     leaves and move on to the repositories they borrow from.\n\n (2) In each repository, run \"repack -a -l -d\".  By doing this for a\n     repository that borrows from another repacks the former without\n     objects it borrows from the latter, so the former repository will\n     retain what it needs but will borrow what are common from the\n     latter, so you start from the repository that does not borrow from\n     anybody else, and move on to the repositories that borrow from the\n     one you already run this step.\n"},{"id":"62438","messageId":"20071208234414.GA31121@sigill.intra.peff.net","threadId":"11195","inReplyTo":"7vsl2cvpef.fsf@gitster.siamese.dyndns.org","subject":"Re: Removing redundant packs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-12-08T23:44:15Z","receivedAt":"2007-12-08T23:44:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Dec 08, 2007 at 01:37:44PM -0800, Junio C Hamano wrote:\n\n>  (1) In each repository, run \"repack -a -d\".  That would ensure that\n>      everybody has the necessary objects that they themselves need.  By\n>      doing this for a repository that borrows from another makes sure\n>      pruning the latter would not break the former, so you start from\n>      leaves and move on to the repositories they borrow from.\n\nI'm not sure this works. Try this:\n\n# make parent repo with two commits, fully packed\nmkdir parent && cd parent && git init &&\necho content >file && git add file && git commit -m added &&\necho more >>file && git commit -m more -a &&\ngit repack -a -d\n\n# clone child repo with alternates\ngit clone -s . ../child\n\n# and now forget about the second commit in the parent\ngit reset --hard HEAD^\nrm -rf .git/logs\n\n# at this point the \"parent\" repo doesn't know anything about the second\n# commit, but contains the objects; the child repo does know about it,\n# but relies on the pack in the parent for the objects\n\n# so your advice is to \"repack -a -d\" first in the child, then in the\n# parent.\n# child first; output will be: \"Nothing new to pack.\"\ncd ../child && git repack -a -d\n# and then parent, which will lose the objects for the second commit\ncd ../parent && git repack -a -d\n\n# and confirm that child is broken\n# output is: \"fatal: bad object HEAD\"\ncd ../child && PAGER=cat git show\n\nYou seem to think that repacking without \"-l\" will pull objects from\nalternates, but it doesn't (I have also seen \"repack -a -d\" recommended\nfor \"how do I break alternates dependencies\", but it obviously also\ndoesn't work for that).\n\n-Peff\n"},{"id":"62439","messageId":"20071208235032.GB31121@sigill.intra.peff.net","threadId":"11195","inReplyTo":"20071208234414.GA31121@sigill.intra.peff.net","subject":"Re: Removing redundant packs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-12-08T23:50:32Z","receivedAt":"2007-12-08T23:50:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Dec 08, 2007 at 06:44:15PM -0500, Jeff King wrote:\n\n> You seem to think that repacking without \"-l\" will pull objects from\n> alternates, but it doesn't (I have also seen \"repack -a -d\" recommended\n> for \"how do I break alternates dependencies\", but it obviously also\n> doesn't work for that).\n\nAnd by \"you seem to think\" I obviously don't mean \"stupid n00b, you\ndon't understand git\" but \"I'm unclear on what the behavior should be.\nYou seem to be saying this, which means this is a serious bug.\"\n\n-Peff\n"}]}