]> git.ipfire.org Git - thirdparty/git.git/commitdiff
stripspace: respect repository config
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 21 Nov 2016 14:18:24 +0000 (15:18 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Nov 2016 19:00:38 +0000 (11:00 -0800)
The way "git stripspace" reads the configuration was not quite
kosher, in that the code forgot to probe for a possibly existing
repository (note: stripspace is designed to be usable outside the
repository as well).  It read .git/config only when it was run from
the top-level of the working tree by accident.  A recent change
b9605bc4f2 ("config: only read .git/config from configured repos",
2016-09-12) stopped reading the repository-local configuration file
".git/config" unless the repository discovery process is done, so
that .git/config is never read even when run from the top-level,
exposing the old bug more.

When rebasing interactively with a commentChar defined in the
current repository's config, the help text at the bottom of the edit
script potentially used an incorrect comment character. This was not
only funny-looking, but also resulted in tons of warnings like this
one:

Warning: the command isn't recognized in the following line
 - #

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/stripspace.c
t/t0030-stripspace.sh

index 15e716ef4322bb53428685c349aa489ed84a6dda..1e62a008cbc57691c6a0055f0286a2c11d1e3122 100644 (file)
@@ -44,8 +44,10 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
        if (argc)
                usage_with_options(stripspace_usage, options);
 
-       if (mode == STRIP_COMMENTS || mode == COMMENT_LINES)
+       if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
+               setup_git_directory_gently(NULL);
                git_config(git_default_config, NULL);
+       }
 
        if (strbuf_read(&buf, 0, 1024) < 0)
                die_errno("could not read the input");
index c1f6411eb2d8d04585faf6d9289bd50d7c5f52cf..bbf3e39e3d229fbda5b7e40e9caca3aba2e1f52b 100755 (executable)
@@ -432,7 +432,7 @@ test_expect_success '-c with changed comment char' '
        test_cmp expect actual
 '
 
-test_expect_failure '-c with comment char defined in .git/config' '
+test_expect_success '-c with comment char defined in .git/config' '
        test_config core.commentchar = &&
        printf "= foo\n" >expect &&
        printf "foo" | (