Skip to content

Commit 92068ae

Browse files
dschogitster
authored andcommitted
stripspace: respect repository config
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 b9605bc ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6645838 commit 92068ae

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

builtin/stripspace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
4444
if (argc)
4545
usage_with_options(stripspace_usage, options);
4646

47-
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES)
47+
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
48+
setup_git_directory_gently(NULL);
4849
git_config(git_default_config, NULL);
50+
}
4951

5052
if (strbuf_read(&buf, 0, 1024) < 0)
5153
die_errno("could not read the input");

t/t0030-stripspace.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ test_expect_success '-c with changed comment char' '
432432
test_cmp expect actual
433433
'
434434

435-
test_expect_failure '-c with comment char defined in .git/config' '
435+
test_expect_success '-c with comment char defined in .git/config' '
436436
test_config core.commentchar = &&
437437
printf "= foo\n" >expect &&
438438
printf "foo" | (

0 commit comments

Comments
 (0)