#!/bin/sh
+USAGE='[-n] [--] [<head>...]'
. git-sh-setup
dryrun=
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
-redundant=$(git-pack-redundant --all)
-if test "" != "$redundant"
+if redundant=$(git-pack-redundant --all 2>/dev/null) && test "" != "$redundant"
then
if test "" = "$dryrun"
then