Re: [PATCH 2/3] stripspace: respect repository config
From: Junio C Hamano <hidden>
Date: 2016-11-21 20:28:59
Junio C Hamano [off-list ref] writes:
From: Johannes Schindelin <redacted>
The way "git stripspace" reads the configuration was not quite
correct, in that it forgot to probe for a possibly existing
repository (note: stripspace is designed to be usable outside the
repository as well) before doing so. Due to this, .git/config was
read only when the command was run from the top-level of the working
tree.
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, and ".git/config" is no longer read even when run
from the top-level, which exposed the bug even more.
The above two paragraphs are rewritten from the original to explain
how this seemed to work (by accident) and its breakage surfaced in
"rebase -i" after b9605bc4f2 ("config: only read .git/config from
configured repos", 2016-09-12) better. The use of stripspace in
"rebase-i" was done after cd_to_toplevel and it happened to work
before that commit.
Otherwise there is no change from the original.
quoted hunk
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 <redacted> Signed-off-by: Junio C Hamano <redacted> --- builtin/stripspace.c | 4 +++- t/t0030-stripspace.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)diff --git a/builtin/stripspace.c b/builtin/stripspace.c index 15e716ef43..1e62a008cb 100644 --- a/builtin/stripspace.c +++ b/builtin/stripspace.c@@ -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");diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index c1f6411eb2..bbf3e39e3d 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh@@ -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" | (