Fix bunch of fd leaks in http-fetch
[git/dscho.git] / git-repack.sh
blobf34720701b0a666823bcde0da3d5b67cd2b54d9e
1 #!/bin/sh
3 # Copyright (c) 2005 Linus Torvalds
6 . git-sh-setup || die "Not a git archive"
8 no_update_info= all_into_one= remove_redundant= local=
9 while case "$#" in 0) break ;; esac
11 case "$1" in
12 -n) no_update_info=t ;;
13 -a) all_into_one=t ;;
14 -d) remove_redandant=t ;;
15 -l) local=t ;;
16 *) break ;;
17 esac
18 shift
19 done
21 rm -f .tmp-pack-*
22 PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
24 # There will be more repacking strategies to come...
25 case ",$all_into_one," in
26 ,,)
27 rev_list='--unpacked'
28 rev_parse='--all'
29 pack_objects='--incremental'
31 ,t,)
32 rev_list=
33 rev_parse='--all'
34 pack_objects=
36 esac
37 if [ "$local" ]; then
38 pack_objects="$pack_objects --local"
40 name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
41 git-pack-objects --non-empty $pack_objects .tmp-pack) ||
42 exit 1
43 if [ -z "$name" ]; then
44 echo Nothing new to pack.
45 if test "$remove_redandant" = t ; then
46 echo "Removing redundant packs."
47 sync
48 redundant=$(git-pack-redundant --all)
49 if test "$redundant" != "" ; then
50 echo $redundant | xargs rm
53 exit 0
55 echo "Pack pack-$name created."
57 mkdir -p "$PACKDIR" || exit
59 mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
60 mv .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" ||
61 exit
63 if test "$remove_redandant" = t
64 then
65 sync
66 redundant=$(git-pack-redundant --all)
67 if test "$redundant" != "" ; then
68 echo $redundant | xargs rm
72 case "$no_update_info" in
73 t) : ;;
74 *) git-update-server-info ;;
75 esac