Make the name of a pack-file depend on the objects packed there-in.
[git/jnareb-git.git] / git-prune-script
blobec9f72de793f88a82ea7b9780c76c4f665264d02
1 #!/bin/sh
2 dryrun=
3 while case "$#" in 0) break ;; esac
4 do
5 case "$1" in
6 -n) dryrun=echo ;;
7 --) break ;;
8 -*) echo >&2 "usage: git-prune-script [ -n ] [ heads... ]"; exit 1 ;;
9 *) break ;;
10 esac
11 shift;
12 done
14 : ${GIT_DIR=.git}
15 : ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
17 git-fsck-cache --cache --unreachable "$@" |
18 sed -ne '/unreachable /{
19 s/unreachable [^ ][^ ]* //
20 s|\(..\)|\1/|p
21 }' | {
22 cd "$GIT_OBJECT_DIRECTORY" || exit
23 xargs -r $dryrun rm -f