aboutsummaryrefslogtreecommitdiff
path: root/t/t0001-init.sh
diff options
context:
space:
mode:
authorDeskin Miller <deskinm@umich.edu>2008-10-07 01:37:48 -0400
committerShawn O. Pearce <spearce@spearce.org>2008-10-08 07:18:44 -0700
commit0a2c7eea41867ead2b2fb1d5898494c3a72405e5 (patch)
tree1d7f37adb2db0e4a944132e95a3e2d5ca9bdae41 /t/t0001-init.sh
parentbf07cc58aeb84b1262cc58f571d2f7033474efa7 (diff)
downloadgit-0a2c7eea41867ead2b2fb1d5898494c3a72405e5.tar.gz
git-0a2c7eea41867ead2b2fb1d5898494c3a72405e5.tar.xz
git init: --bare/--shared overrides system/global config
If core.bare or core.sharedRepository are set in /etc/gitconfig or ~/.gitconfig, then 'git init' will read the values when constructing a new config file; reading them, however, will override the values specified on the command line. In the case of --bare, this ends up causing a segfault, without the repository being properly initialised; in the case of --shared, the permissions are set according to the existing config settings, not what was specified on the command line. This fix saves any specified values for --bare and --shared prior to reading existing config settings, and restores them after reading but before writing the new config file. core.bare is ignored in all situations, while core.sharedRepository will only be used if --shared is not specified to git init. Also includes testcases which use a specified global config file override, demonstrating the former failure scenario. Signed-off-by: Deskin Miller <deskinm@umich.edu> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 't/t0001-init.sh')
-rwxr-xr-xt/t0001-init.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 620da5b32..5ac0a273a 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -167,4 +167,36 @@ test_expect_success 'init with --template (blank)' '
! test -f template-blank/.git/info/exclude
'
+test_expect_success 'init --bare/--shared overrides system/global config' '
+ (
+ HOME="`pwd`" &&
+ export HOME &&
+ test_config="$HOME"/.gitconfig &&
+ unset GIT_CONFIG_NOGLOBAL &&
+ git config -f "$test_config" core.bare false &&
+ git config -f "$test_config" core.sharedRepository 0640 &&
+ mkdir init-bare-shared-override &&
+ cd init-bare-shared-override &&
+ git init --bare --shared=0666
+ ) &&
+ check_config init-bare-shared-override true unset &&
+ test x0666 = \
+ x`git config -f init-bare-shared-override/config core.sharedRepository`
+'
+
+test_expect_success 'init honors global core.sharedRepository' '
+ (
+ HOME="`pwd`" &&
+ export HOME &&
+ test_config="$HOME"/.gitconfig &&
+ unset GIT_CONFIG_NOGLOBAL &&
+ git config -f "$test_config" core.sharedRepository 0666 &&
+ mkdir shared-honor-global &&
+ cd shared-honor-global &&
+ git init
+ ) &&
+ test x0666 = \
+ x`git config -f shared-honor-global/.git/config core.sharedRepository`
+'
+
test_done