archimport: remove git wrapper dependency
[git/mingw.git] / git-prune.sh
blob7e7f0ad56d381dc546f1bc598e41c1d7fa1e3a36
1 #!/bin/sh
3 . git-sh-setup
5 dryrun=
6 echo=
7 while case "$#" in 0) break ;; esac
8 do
9 case "$1" in
10 -n) dryrun=-n echo=echo ;;
11 --) break ;;
12 -*) echo >&2 "usage: git-prune [ -n ] [ heads... ]"; exit 1 ;;
13 *) break ;;
14 esac
15 shift;
16 done
18 sync
19 case "$#" in
20 0) git-fsck-objects --full --cache --unreachable ;;
21 *) git-fsck-objects --full --cache --unreachable $(git-rev-parse --all) "$@" ;;
22 esac |
24 sed -ne '/unreachable /{
25 s/unreachable [^ ][^ ]* //
26 s|\(..\)|\1/|p
27 }' | {
28 cd "$GIT_OBJECT_DIRECTORY" || exit
29 xargs $echo rm -f
30 rmdir 2>/dev/null [0-9a-f][0-9a-f]
33 git-prune-packed $dryrun
35 redundant=$(git-pack-redundant --all)
36 if test "" != "$redundant"
37 then
38 if test "" = "$dryrun"
39 then
40 echo "$redundant" | xargs rm -f
41 else
42 echo rm -f "$redundant"