rev-list --remove-empty: add minimum help and doc entry.
[git/jrn.git] / git-prune.sh
blobc5a5d29aaacf753b70e715169cbb7f74f0193e4a
1 #!/bin/sh
3 USAGE='[-n] [--] [<head>...]'
4 . git-sh-setup
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
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 |
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]
34 git-prune-packed $dryrun
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"