]> git.ipfire.org Git - thirdparty/git.git/blame - git-prune.sh
fix potential deadlock in create_one_file
[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
JH
35
36redundant=$(git-pack-redundant --all)
37if test "" != "$redundant"
38then
c3e24a7d 39 if test "" = "$dryrun"
d7b1a1dd
JH
40 then
41 echo "$redundant" | xargs rm -f
42 else
43 echo rm -f "$redundant"
44 fi
45fi