Skip to content

Commit b0e67ff

Browse files
committed
Merge branch 'jh/maint-config-file-prefix' into maint
* jh/maint-config-file-prefix: builtin-config: Fix crash when using "-f <relative path>" from non-root dir
2 parents 2e9d733 + 65807ee commit b0e67ff

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

builtin-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
340340
if (!is_absolute_path(given_config_file) && prefix)
341341
config_exclusive_filename = prefix_filename(prefix,
342342
strlen(prefix),
343-
argv[2]);
343+
given_config_file);
344344
else
345345
config_exclusive_filename = given_config_file;
346346
}

t/t1300-repo-config.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,17 @@ test_expect_success 'alternative GIT_CONFIG' 'cmp output expect'
398398
test_expect_success 'alternative GIT_CONFIG (--file)' \
399399
'git config --file other-config -l > output && cmp output expect'
400400

401+
test_expect_success 'refer config from subdirectory' '
402+
mkdir x &&
403+
(
404+
cd x &&
405+
echo strasse >expect
406+
git config --get --file ../other-config ein.bahn >actual &&
407+
test_cmp expect actual
408+
)
409+
410+
'
411+
401412
GIT_CONFIG=other-config git config anwohner.park ausweis
402413

403414
cat > expect << EOF

0 commit comments

Comments
 (0)