diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2019-07-21 01:52:05 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2019-07-21 16:22:07 +0100 |
commit | cec005037f5b62cb17094df53fb25c066d6a9705 (patch) | |
tree | 56fe62560698fa6e47bd0146a4f0da55cc6369cd /git-playtree-create | |
parent | 698dc5075b0494a8ba396e1bd0a785443b10f7ff (diff) |
git-playtree-setup: Rewrite in shell and call it from Perl
We want this because git-debpush is going to want this functionality
but doesn't want to include (or have a copy of) Dgit.pm.
The installation arrangements are rather ugly.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'git-playtree-create')
-rwxr-xr-x | git-playtree-create | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/git-playtree-create b/git-playtree-create new file mode 100755 index 0000000..5d890a0 --- /dev/null +++ b/git-playtree-create @@ -0,0 +1,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 -ex + +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 |