2005-04-18 19:15:10 +00:00
|
|
|
#!/bin/sh
|
2005-05-04 08:33:33 +00: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 05:57:58 +00:00
|
|
|
: ${GIT_DIR=.git}
|
|
|
|
: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
|
|
|
|
|
2005-05-04 08:33:33 +00:00
|
|
|
git-fsck-cache --cache --unreachable "$@" |
|
|
|
|
sed -ne '/unreachable /{
|
|
|
|
s/unreachable [^ ][^ ]* //
|
|
|
|
s|\(..\)|\1/|p
|
|
|
|
}' | {
|
2005-05-10 05:57:58 +00:00
|
|
|
cd "$GIT_OBJECT_DIRECTORY" || exit
|
2005-05-04 08:33:33 +00:00
|
|
|
xargs -r $dryrun rm -f
|
|
|
|
}
|
2005-05-10 05:57:58 +00:00
|
|
|
|