summaryrefslogtreecommitdiff
path: root/git-playtree-setup
blob: 184de4d69d03cc8a0bb3a05b68999be6601a7687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#
# usage:
#   rm -rf .git/some/play/thing
#   git-playtree-setup .git/some/play/thing
# or:
#   mkdir .git/some/play/thing
#   cd .git/some/play/thing
#   git-playtree-setup .

set -e${GIT_PLAYTREE_SETUP_DEBUG}

target=$1; shift

case "$#.$target" in
0.[^-]*) ;;
*) echo >&2 'bad usage' ; exit 8 ;;
esac

[ "x$target" = x. ] || mkdir $target
cd $target

gcd=$(cd .. && git rev-parse --git-common-dir)
case "$gcd" in
/*) ;;
*) gcd="../$gcd" ;;
esac

git init -q
git config gc.auto 0

unset_all () { git config --local --unset-all $key || [ $? = 5 ]; }

for key in \
                         user.email user.name user.useConfigOnly \
                         core.sharedRepository                   \
                         core.compression core.looseCompression  \
                         core.bigFileThreshold core.fsyncObjectFiles \
; do
	unset_all
	(
		git --git-dir="$gcd" config -z --get-all $key || [ $? = 1 ]
	) | xargs -n1 -0r -- \
		git config --local --add $key
done

rm -rf .git/objects
ln -s "$gcd/objects" .git/objects