Code

Merge branch 'jh/maint-config-file-prefix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 27 Jan 2010 22:56:25 +0000 (14:56 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Jan 2010 22:56:25 +0000 (14:56 -0800)
* jh/maint-config-file-prefix:
  builtin-config: Fix crash when using "-f <relative path>" from non-root dir

builtin-config.c
t/t1300-repo-config.sh

index 2e3ef911d6d6682bc2f71ea912b05768fb6298be..4bc46b15fde00d913577a2980778746f8315bb70 100644 (file)
@@ -358,7 +358,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
                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;
        }
index f89d7e9e4959ddccafafd11c5fbf9f4b06541578..f11f98c3ce7e35f61d06542ce707d61b98079fda 100755 (executable)
@@ -398,6 +398,17 @@ test_expect_success 'alternative GIT_CONFIG' 'cmp output expect'
 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