]> git.ipfire.org Git - thirdparty/git.git/blame - git-prune.sh
symref support for import scripts
[thirdparty/git.git] / git-prune.sh
CommitLineData
839a7a06 1#!/bin/sh
b33e9666 2
215a7ad1 3. git-sh-setup || die "Not a git archive"
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
215a7ad1 19git-fsck-objects --full --cache --unreachable "$@" |
ae7c0c92
JH
20sed -ne '/unreachable /{
21 s/unreachable [^ ][^ ]* //
22 s|\(..\)|\1/|p
23}' | {
8ac069ac 24 cd "$GIT_OBJECT_DIRECTORY" || exit
51890a64 25 xargs $echo rm -f
9106c097 26 rmdir 2>/dev/null [0-9a-f][0-9a-f]
ae7c0c92 27}
8ac069ac 28
51890a64 29git-prune-packed $dryrun
d7b1a1dd
JH
30
31redundant=$(git-pack-redundant --all)
32if test "" != "$redundant"
33then
34 if test "" = $dryrun
35 then
36 echo "$redundant" | xargs rm -f
37 else
38 echo rm -f "$redundant"
39 fi
40fi