#!/bin/sh
-. git-sh-setup || die "Not a git archive"
+USAGE='[-n] [--] [<head>...]'
+. git-sh-setup
dryrun=
echo=
case "$1" in
-n) dryrun=-n echo=echo ;;
--) break ;;
- -*) echo >&2 "usage: git-prune [ -n ] [ heads... ]"; exit 1 ;;
+ -*) usage ;;
*) break ;;
esac
shift;
done
sync
-git-fsck-objects --full --cache --unreachable "$@" |
+case "$#" in
+0) git-fsck-objects --full --cache --unreachable ;;
+*) git-fsck-objects --full --cache --unreachable $(git-rev-parse --all) "$@" ;;
+esac |
+
sed -ne '/unreachable /{
s/unreachable [^ ][^ ]* //
s|\(..\)|\1/|p
}
git-prune-packed $dryrun
+
+if redundant=$(git-pack-redundant --all 2>/dev/null) && test "" != "$redundant"
+then
+ if test "" = "$dryrun"
+ then
+ echo "$redundant" | xargs rm -f
+ else
+ echo rm -f "$redundant"
+ fi
+fi