chiark / gitweb /
changelog: Start 9.8
[dgit.git] / git-playtree-setup
1 #!/bin/bash
2 #
3 # usage:
4 #   rm -rf .git/some/play/thing
5 #   git-playtree-setup .git/some/play/thing
6 # or:
7 #   mkdir .git/some/play/thing
8 #   cd .git/some/play/thing
9 #   git-playtree-setup .
10
11 set -e${GIT_PLAYTREE_SETUP_DEBUG}
12
13 target=$1; shift
14
15 case "$#.$target" in
16 0.[^-]*) ;;
17 *) echo >&2 'bad usage' ; exit 8 ;;
18 esac
19
20 [ "x$target" = x. ] || mkdir $target
21 cd $target
22
23 gcd=$(cd .. && git rev-parse --git-common-dir)
24 case "$gcd" in
25 /*) ;;
26 *) gcd="../$gcd" ;;
27 esac
28
29 git init -q
30 git config gc.auto 0
31
32 unset_all () { git config --local --unset-all $key || [ $? = 5 ]; }
33
34 for key in \
35                          user.email user.name user.useConfigOnly \
36                          core.sharedRepository                   \
37                          core.compression core.looseCompression  \
38                          core.bigFileThreshold core.fsyncObjectFiles \
39 ; do
40         unset_all
41         (
42                 git --git-dir="$gcd" config -z --get-all $key || [ $? = 1 ]
43         ) | xargs -n1 -0r -- \
44                 git config --local --add $key
45 done
46
47 rm -rf .git/objects
48 ln -s "$gcd/objects" .git/objects