File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -871,9 +871,7 @@ int git_config(config_fn_t fn, void *data)
871
871
if (config_parameters )
872
872
found += 1 ;
873
873
874
- if (found == 0 )
875
- return -1 ;
876
- return ret ;
874
+ return ret == 0 ? found : ret ;
877
875
}
878
876
879
877
/*
Original file line number Diff line number Diff line change 288
288
test_expect_success ' working --list' \
289
289
' git config --list > output && cmp output expect'
290
290
291
+ cat > expect << EOF
292
+ EOF
293
+
294
+ test_expect_success ' --list without repo produces empty output' '
295
+ git --git-dir=nonexistent config --list >output &&
296
+ test_cmp expect output
297
+ '
298
+
291
299
cat > expect << EOF
292
300
beta.noindent sillyValue
293
301
nextsection.nonewline wow2 for me
@@ -836,6 +844,27 @@ test_expect_success SYMLINKS 'symlinked configuration' '
836
844
837
845
'
838
846
847
+ test_expect_success ' nonexistent configuration' '
848
+ (
849
+ GIT_CONFIG=doesnotexist &&
850
+ export GIT_CONFIG &&
851
+ test_must_fail git config --list &&
852
+ test_must_fail git config test.xyzzy
853
+ )
854
+ '
855
+
856
+ test_expect_success SYMLINKS ' symlink to nonexistent configuration' '
857
+ ln -s doesnotexist linktonada &&
858
+ ln -s linktonada linktolinktonada &&
859
+ (
860
+ GIT_CONFIG=linktonada &&
861
+ export GIT_CONFIG &&
862
+ test_must_fail git config --list &&
863
+ GIT_CONFIG=linktolinktonada &&
864
+ test_must_fail git config --list
865
+ )
866
+ '
867
+
839
868
test_expect_success ' check split_cmdline return' "
840
869
git config alias.split-cmdline-fix 'echo \" ' &&
841
870
test_must_fail git split-cmdline-fix &&
You can’t perform that action at this time.
0 commit comments