]> git.ipfire.org Git - thirdparty/git.git/blame - git-prune.sh
Documentation: more examples.
[thirdparty/git.git] / git-prune.sh
CommitLineData
839a7a06 1#!/bin/sh
b33e9666 2
ae2b0f15 3. git-sh-setup
b33e9666 4
ae7c0c92 5dryrun=
51890a64 6echo=
ae7c0c92
JH
7while case "$#" in 0) break ;; esac
8do
9 case "$1" in
51890a64 10 -n) dryrun=-n echo=echo ;;
ae7c0c92 11 --) break ;;
215a7ad1 12 -*) echo >&2 "usage: git-prune [ -n ] [ heads... ]"; exit 1 ;;
ae7c0c92
JH
13 *) break ;;
14 esac
15 shift;
16done
17
41f222e8 18sync
2b86976b
JH
19case "$#" in
200) git-fsck-objects --full --cache --unreachable ;;
21*) git-fsck-objects --full --cache --unreachable $(git-rev-parse --all) "$@" ;;
22esac |
23
ae7c0c92
JH
24sed -ne '/unreachable /{
25 s/unreachable [^ ][^ ]* //
26 s|\(..\)|\1/|p
27}' | {
8ac069ac 28 cd "$GIT_OBJECT_DIRECTORY" || exit
51890a64 29 xargs $echo rm -f
9106c097 30 rmdir 2>/dev/null [0-9a-f][0-9a-f]
ae7c0c92 31}
8ac069ac 32
51890a64 33git-prune-packed $dryrun
d7b1a1dd
JH
34
35redundant=$(git-pack-redundant --all)
36if test "" != "$redundant"
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