]> git.ipfire.org Git - thirdparty/git.git/blob - git-prune.sh
Use symbolic name SHORT_NAME_AMBIGUOUS as error return value
[thirdparty/git.git] / git-prune.sh
1 #!/bin/sh
2
3 USAGE='[-n] [--] [<head>...]'
4 . git-sh-setup
5
6 dryrun=
7 echo=
8 while case "$#" in 0) break ;; esac
9 do
10 case "$1" in
11 -n) dryrun=-n echo=echo ;;
12 --) break ;;
13 -*) usage ;;
14 *) break ;;
15 esac
16 shift;
17 done
18
19 sync
20 case "$#" in
21 0) git-fsck-objects --full --cache --unreachable ;;
22 *) git-fsck-objects --full --cache --unreachable $(git-rev-parse --all) "$@" ;;
23 esac |
24
25 sed -ne '/unreachable /{
26 s/unreachable [^ ][^ ]* //
27 s|\(..\)|\1/|p
28 }' | {
29 cd "$GIT_OBJECT_DIRECTORY" || exit
30 xargs $echo rm -f
31 rmdir 2>/dev/null [0-9a-f][0-9a-f]
32 }
33
34 git-prune-packed $dryrun
35
36 if redundant=$(git-pack-redundant --all 2>/dev/null) && test "" != "$redundant"
37 then
38 if test "" = "$dryrun"
39 then
40 echo "$redundant" | xargs rm -f
41 else
42 echo rm -f "$redundant"
43 fi
44 fi