Skip to content

Commit

Permalink
Merge branch 'jk/missing-config'
Browse files Browse the repository at this point in the history
* jk/missing-config:
  config: treat non-existent config files as empty
  • Loading branch information
Junio C Hamano committed Nov 17, 2010
2 parents 44e4155 + 1f2baa7 commit 6f49ed6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 1 addition & 3 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,7 @@ int git_config(config_fn_t fn, void *data)
if (config_parameters)
found += 1;

if (found == 0)
return -1;
return ret;
return ret == 0 ? found : ret;
}

/*
Expand Down
29 changes: 29 additions & 0 deletions t/t1300-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ EOF
test_expect_success 'working --list' \
'git config --list > output && cmp output expect'

cat > expect << EOF
EOF

test_expect_success '--list without repo produces empty output' '
git --git-dir=nonexistent config --list >output &&
test_cmp expect output
'

cat > expect << EOF
beta.noindent sillyValue
nextsection.nonewline wow2 for me
Expand Down Expand Up @@ -836,6 +844,27 @@ test_expect_success SYMLINKS 'symlinked configuration' '
'

test_expect_success 'nonexistent configuration' '
(
GIT_CONFIG=doesnotexist &&
export GIT_CONFIG &&
test_must_fail git config --list &&
test_must_fail git config test.xyzzy
)
'

test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
ln -s doesnotexist linktonada &&
ln -s linktonada linktolinktonada &&
(
GIT_CONFIG=linktonada &&
export GIT_CONFIG &&
test_must_fail git config --list &&
GIT_CONFIG=linktolinktonada &&
test_must_fail git config --list
)
'

test_expect_success 'check split_cmdline return' "
git config alias.split-cmdline-fix 'echo \"' &&
test_must_fail git split-cmdline-fix &&
Expand Down

0 comments on commit 6f49ed6

Please sign in to comment.