git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@SteelEye.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] make git-prune-script actually work
Date: Sun, 24 Apr 2005 08:58:55 -0500	[thread overview]
Message-ID: <1114351135.4997.18.camel@mulgrave> (raw)

I find this script very useful to get back to where I started from after
test merges, and also for cloning trees from a non-current base.  The
functionality is altered so it now takes an optional commit argument
(and a -q flag to make it be quiet).

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

--- a/git-prune-script
+++ b/git-prune-script
@@ -1,2 +1,23 @@
 #!/bin/sh
-fsck-cache --unreachable $(cat .git/HEAD ) | grep unreachable | cut -d' ' -f3 | sed 's:^\(..\):.git/objects/\1/:' | xargs rm
+verbose=true
+case $1 in 
+	-q)	verbose=false
+		shift;;
+esac
+head=$1
+if [ -z "$head" ]; then
+	head=$(cat .git/HEAD)
+fi
+f=$(fsck-cache --unreachable $head | awk '/^unreachable /{print $3}'| sed 's:^\(..\):.git/objects/\1/:')
+if [ -z "$f" ]; then
+	echo "Nothing to remove"
+	exit 0
+fi
+
+for g in $f; do
+	if $verbose; then
+		echo $g
+	fi
+	rm -f $g
+done
+echo $head > .git/HEAD



             reply	other threads:[~2005-04-24 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-24 13:58 James Bottomley [this message]
2005-04-24 17:35 ` [PATCH] make git-prune-script actually work Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1114351135.4997.18.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).