]> git.ipfire.org Git - thirdparty/git.git/blame - git-repack.sh
Remove 'Previously this command was known as ...' messages.
[thirdparty/git.git] / git-repack.sh
CommitLineData
b2d46199 1#!/bin/sh
ccf1ee32
JH
2#
3# Copyright (c) 2005 Linus Torvalds
4#
5
215a7ad1 6. git-sh-setup || die "Not a git archive"
b33e9666 7
f7aac2ea 8no_update_info= all_into_one= remove_redundant= local=
ccf1ee32
JH
9while case "$#" in 0) break ;; esac
10do
11 case "$1" in
12 -n) no_update_info=t ;;
d5acdcf1
JH
13 -a) all_into_one=t ;;
14 -d) remove_redandant=t ;;
f7aac2ea 15 -l) local=t ;;
ccf1ee32
JH
16 *) break ;;
17 esac
18 shift
19done
20
5f3de58f 21rm -f .tmp-pack-*
d5acdcf1
JH
22PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
23
24# There will be more repacking strategies to come...
25case ",$all_into_one," in
26,,)
27 rev_list='--unpacked'
28 rev_parse='--all'
29 pack_objects='--incremental'
30 ;;
31,t,)
32 rev_list=
33 rev_parse='--all'
34 pack_objects=
35 # This part is a stop-gap until we have proper pack redundancy
36 # checker.
37 existing=`cd "$PACKDIR" && \
38 find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
39 ;;
40esac
f7aac2ea
LT
41if [ "$local" ]; then
42 pack_objects="$pack_objects --local"
43fi
d5acdcf1
JH
44name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
45 git-pack-objects --non-empty $pack_objects .tmp-pack) ||
b2d46199 46 exit 1
d5acdcf1
JH
47if [ -z "$name" ]; then
48 echo Nothing new to pack.
b2d46199
LT
49 exit 0
50fi
d5acdcf1
JH
51echo "Pack pack-$name created."
52
53mkdir -p "$PACKDIR" || exit
54
55mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
56mv .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" ||
57exit
58
59if test "$remove_redandant" = t
60then
61 # We know $existing are all redandant only when
62 # all-into-one is used.
63 if test "$all_into_one" != '' && test "$existing" != ''
64 then
41f222e8 65 sync
490e23d2
JH
66 ( cd "$PACKDIR" &&
67 for e in $existing
68 do
69 case "$e" in
70 ./pack-$name.pack | ./pack-$name.idx) ;;
71 *) rm -f $e ;;
72 esac
73 done
74 )
d5acdcf1
JH
75 fi
76fi
ccf1ee32 77
ccf1ee32
JH
78case "$no_update_info" in
79t) : ;;
80*) git-update-server-info ;;
81esac