2005-04-18 21:15:10 +02:00
|
|
|
#!/bin/sh
|
2005-05-04 10:33:33 +02:00
|
|
|
dryrun=
|
|
|
|
while case "$#" in 0) break ;; esac
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
-n) dryrun=echo ;;
|
|
|
|
--) break ;;
|
|
|
|
-*) echo >&2 "usage: git-prune-script [ -n ] [ heads... ]"; exit 1 ;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
shift;
|
|
|
|
done
|
|
|
|
|
2005-05-10 07:57:58 +02:00
|
|
|
: ${GIT_DIR=.git}
|
|
|
|
: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
|
|
|
|
|
2005-05-04 10:33:33 +02:00
|
|
|
git-fsck-cache --cache --unreachable "$@" |
|
|
|
|
sed -ne '/unreachable /{
|
|
|
|
s/unreachable [^ ][^ ]* //
|
|
|
|
s|\(..\)|\1/|p
|
|
|
|
}' | {
|
2005-05-10 07:57:58 +02:00
|
|
|
cd "$GIT_OBJECT_DIRECTORY" || exit
|
2005-05-04 10:33:33 +02:00
|
|
|
xargs -r $dryrun rm -f
|
|
|
|
}
|
2005-05-10 07:57:58 +02:00
|
|
|
|