combine-diff: type fix.
[git/gitweb.git] / git-repack.sh
bloba5d349fd099a8d2a411d1b71ef8a6ff5d368ba32
1 #!/bin/sh
3 # Copyright (c) 2005 Linus Torvalds
6 USAGE='[-a] [-d] [-f] [-l] [-n] [-q]'
7 . git-sh-setup
9 no_update_info= all_into_one= remove_redundant=
10 local= quiet= no_reuse_delta=
11 while case "$#" in 0) break ;; esac
13 case "$1" in
14 -n) no_update_info=t ;;
15 -a) all_into_one=t ;;
16 -d) remove_redundant=t ;;
17 -q) quiet=-q ;;
18 -f) no_reuse_delta=--no-reuse-delta ;;
19 -l) local=--local ;;
20 *) usage ;;
21 esac
22 shift
23 done
25 rm -f .tmp-pack-*
26 PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
28 # There will be more repacking strategies to come...
29 case ",$all_into_one," in
30 ,,)
31 rev_list='--unpacked'
32 pack_objects='--incremental'
34 ,t,)
35 rev_list=
36 pack_objects=
38 # Redundancy check in all-into-one case is trivial.
39 existing=`cd "$PACKDIR" && \
40 find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
42 esac
43 pack_objects="$pack_objects $local $quiet $no_reuse_delta"
44 name=$(git-rev-list --objects --all $rev_list 2>&1 |
45 git-pack-objects --non-empty $pack_objects .tmp-pack) ||
46 exit 1
47 if [ -z "$name" ]; then
48 echo Nothing new to pack.
49 exit 0
51 echo "Pack pack-$name created."
53 mkdir -p "$PACKDIR" || exit
55 mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
56 mv .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" ||
57 exit
59 if test "$remove_redundant" = t
60 then
61 # We know $existing are all redundant only when
62 # all-into-one is used.
63 if test "$all_into_one" != '' && test "$existing" != ''
64 then
65 sync
66 ( cd "$PACKDIR" &&
67 for e in $existing
69 case "$e" in
70 ./pack-$name.pack | ./pack-$name.idx) ;;
71 *) rm -f $e ;;
72 esac
73 done
76 git-prune-packed
79 case "$no_update_info" in
80 t) : ;;
81 *) git-update-server-info ;;
82 esac