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

[PATCH] make git-prune-script actually work

From
JBJames Bottomley <james.bottomley@steeleye.com>
Date
Apr 24, 2005, 13:58 UTC
Message-ID
<1114351135.4997.18.camel@mulgrave>

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
Next: Linus Torvalds
Message 1 of 2 in “make git-prune-script actually work”
  1. make git-prune-script actually workJames Bottomley, Apr 24, 2005
  2. Linus TorvaldsApr 24, 2005

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.