summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e276f01)
raw | patch | inline | side by side (parent: e276f01)
author | Johan Herland <johan@herland.net> | |
Tue, 26 Jan 2010 15:02:16 +0000 (16:02 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 26 Jan 2010 19:20:06 +0000 (11:20 -0800) |
When your current directory is not at the root of the working tree, and you
use the "-f" option with a relative path, the current code tries to read
from a wrong file, since argv[2] is now beyond the end of the rearranged
argument list.
This patch replaces the incorrect argv[2] with the variable holding the
given config file name.
The bug was introduced by d64ec16 (git config: reorganize to use parseopt).
[jc: added test]
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
use the "-f" option with a relative path, the current code tries to read
from a wrong file, since argv[2] is now beyond the end of the rearranged
argument list.
This patch replaces the incorrect argv[2] with the variable holding the
given config file name.
The bug was introduced by d64ec16 (git config: reorganize to use parseopt).
[jc: added test]
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-config.c | patch | blob | history | |
t/t1300-repo-config.sh | patch | blob | history |
diff --git a/builtin-config.c b/builtin-config.c
index a81bc8bbf033fac83ad6deecbf4a67ba44e06a0b..5a5d214bb84c8eefa7ce9a1ca55c5689ce698af5 100644 (file)
--- a/builtin-config.c
+++ b/builtin-config.c
if (!is_absolute_path(given_config_file) && prefix)
config_exclusive_filename = prefix_filename(prefix,
strlen(prefix),
- argv[2]);
+ given_config_file);
else
config_exclusive_filename = given_config_file;
}
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 43ea283242c4afc25e53d4a8c894140793649717..c81ccf2e56659b41787b9da69acbb3bf9f44f984 100755 (executable)
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
test_expect_success 'alternative GIT_CONFIG (--file)' \
'git config --file other-config -l > output && cmp output expect'
+test_expect_success 'refer config from subdirectory' '
+ mkdir x &&
+ (
+ cd x &&
+ echo strasse >expect
+ git config --get --file ../other-config ein.bahn >actual &&
+ test_cmp expect actual
+ )
+
+'
+
GIT_CONFIG=other-config git config anwohner.park ausweis
cat > expect << EOF