{"thread":{"id":"286","subject":"[PATCH] make git-prune-script actually work","startedAt":"2005-04-24T13:58:55Z","lastAt":"2005-04-24T17:35:40Z","messageCount":2,"participants":["James Bottomley","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1522","messageId":"1114351135.4997.18.camel@mulgrave","threadId":"286","inReplyTo":null,"subject":"[PATCH] make git-prune-script actually work","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-24T13:58:55Z","receivedAt":"2005-04-24T13:58:55Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"I find this script very useful to get back to where I started from after\ntest merges, and also for cloning trees from a non-current base.  The\nfunctionality is altered so it now takes an optional commit argument\n(and a -q flag to make it be quiet).\n\nSigned-off-by: James Bottomley <James.Bottomley@SteelEye.com>\n\n--- a/git-prune-script\n+++ b/git-prune-script\n@@ -1,2 +1,23 @@\n #!/bin/sh\n-fsck-cache --unreachable $(cat .git/HEAD ) | grep unreachable | cut -d' ' -f3 | sed 's:^\\(..\\):.git/objects/\\1/:' | xargs rm\n+verbose=true\n+case $1 in \n+\t-q)\tverbose=false\n+\t\tshift;;\n+esac\n+head=$1\n+if [ -z \"$head\" ]; then\n+\thead=$(cat .git/HEAD)\n+fi\n+f=$(fsck-cache --unreachable $head | awk '/^unreachable /{print $3}'| sed 's:^\\(..\\):.git/objects/\\1/:')\n+if [ -z \"$f\" ]; then\n+\techo \"Nothing to remove\"\n+\texit 0\n+fi\n+\n+for g in $f; do\n+\tif $verbose; then\n+\t\techo $g\n+\tfi\n+\trm -f $g\n+done\n+echo $head > .git/HEAD\n\n\n"},{"id":"1532","messageId":"Pine.LNX.4.58.0504241032490.15879@ppc970.osdl.org","threadId":"286","inReplyTo":"1114351135.4997.18.camel@mulgrave","subject":"Re: [PATCH] make git-prune-script actually work","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-24T17:35:40Z","receivedAt":"2005-04-24T17:35:40Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 24 Apr 2005, James Bottomley wrote:\n>\n> I find this script very useful to get back to where I started from after\n> test merges, and also for cloning trees from a non-current base.  The\n> functionality is altered so it now takes an optional commit argument\n> (and a -q flag to make it be quiet).\n\nHmm.. You should probably rename it to \"git-reset-script\" or something, \nand any time you reset the head, you should also amke sure to reset the \nindex, because otherwise your index file may actually be referencing \nobjects that no longer even exist, and that's going to be very very \npainful.\n\nSo\n\n> +echo $head > .git/HEAD\n\nshould probably be followed by\n\n\tread-tree -m $head\n\tupdate-cache --refresh\n\nwhich will also tell the user what files he has that are now \"dirty\" (and \nhe can decide whether he wants to commit his changes, or whether he wants \nto do a \"checkout-cache -f -a\" to just get rid of it all).\n\n\t\tLinus\n"}]}