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