]> git.ipfire.org Git - thirdparty/git.git/blame - git-repack-script
[PATCH] archimport autodetects import status, supports incremental imports
[thirdparty/git.git] / git-repack-script
CommitLineData
b2d46199 1#!/bin/sh
ccf1ee32
JH
2#
3# Copyright (c) 2005 Linus Torvalds
4#
5
b33e9666
LT
6. git-sh-setup-script || die "Not a git archive"
7
d5acdcf1 8no_update_info= all_into_one= remove_redundant=
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 ;;
ccf1ee32
JH
15 *) break ;;
16 esac
17 shift
18done
19
5f3de58f 20rm -f .tmp-pack-*
d5acdcf1
JH
21PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
22
23# There will be more repacking strategies to come...
24case ",$all_into_one," in
25,,)
26 rev_list='--unpacked'
27 rev_parse='--all'
28 pack_objects='--incremental'
29 ;;
30,t,)
31 rev_list=
32 rev_parse='--all'
33 pack_objects=
34 # This part is a stop-gap until we have proper pack redundancy
35 # checker.
36 existing=`cd "$PACKDIR" && \
37 find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
38 ;;
39esac
40name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
41 git-pack-objects --non-empty $pack_objects .tmp-pack) ||
b2d46199 42 exit 1
d5acdcf1
JH
43if [ -z "$name" ]; then
44 echo Nothing new to pack.
b2d46199
LT
45 exit 0
46fi
d5acdcf1
JH
47echo "Pack pack-$name created."
48
49mkdir -p "$PACKDIR" || exit
50
51mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
52mv .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" ||
53exit
54
55if test "$remove_redandant" = t
56then
57 # We know $existing are all redandant only when
58 # all-into-one is used.
59 if test "$all_into_one" != '' && test "$existing" != ''
60 then
61 ( cd "$PACKDIR" && rm -f $existing )
62 fi
63fi
ccf1ee32 64
ccf1ee32
JH
65case "$no_update_info" in
66t) : ;;
67*) git-update-server-info ;;
68esac