Fix problems with rebase -i when core.commentchar is defined
cover Fix problems with rebase -i when core.commentchar is defined
The Git for Windows project recently got a bug report that detailed how git rebase -i fails when core.commentchar=auto:
https://groups.google.com/forum/#!topic/git-for-windows/eOZKjkgyX1Q
This patch series fixes rebase -i's handling of core.commentchar.
Johannes Schindelin (3):
rebase -i: identify problems with core.commentchar
stripspace: respect repository config rebase -i: handle core.commentChar=auto
builtin/stripspace.c | 4 +++- git-rebase--interactive.sh | 13 +++++++++++-- t/t0030-stripspace.sh | 7 +++++++ t/t3404-rebase-interactive.sh | 12 ++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-)
base-commit: 1310affe024fba407bff55dbe65cd6d670c8a32d
Published-As: https://github.com/dscho/git/releases/tag/rebase-i-commentchar-v1
Fetch-It-Via: git fetch https://github.com/dscho/git rebase-i-commentchar-v1
Signature · 1 line
2.10.1.583.g721a9e0
PATCH 1/3 rebase -i: identify problems with core.commentchar
The interactive rebase does not currently play well with core.commentchar. Let's add some tests to identify those problems.
--- t/t0030-stripspace.sh | 7 +++++++ t/t3404-rebase-interactive.sh | 12 ++++++++++++ 2 files changed, 19 insertions(+)
t/t0030-stripspace.sh +7 -0
@@ -432,6 +432,13 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual ' +test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | git stripspace -c >actual && + test_cmp expect actual +' + test_expect_success 'avoid SP-HT sequence in commented line' ' printf "#\tone\n#\n# two\n" >expect && printf "\tone\n\ntwo\n" | git stripspace -c >actual &&
t/t3404-rebase-interactive.sh +12 -0
@@ -976,6 +976,18 @@ test_expect_success 'rebase -i respects core.commentchar' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' +test_expect_failure 'rebase -i respects core.commentchar=auto' ' + test_config core.commentchar auto && + write_script copy-edit-script.sh <<-\EOF && + cp "$1" edit-script + EOF + test_set_editor "$(pwd)/copy-edit-script.sh" && + test_when_finished "git rebase --abort || :" && + git rebase -i HEAD^ && + grep "^#" edit-script && + test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)" +' + test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' ' test_when_finished "git branch -D torebase" && git checkout -b torebase branch1 &&
Signature · 1 line
2.10.1.583.g721a9e0
Re: [PATCH 1/3] rebase -i: identify problems with core.commentchar
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 438
Quoted 12 lines · Johannes Schindelin
t/t0030-stripspace.sh +4
-0@@ -432,6 +432,13 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual ' +test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | git stripspace -c >actual &&
We'd want "\n" on this printf to match the one before as well, as this test is not about "does stripspace complete an incomplete line?", I think.
I could amend it while queuing, but I need to know if I am missing a reason why this must be an incomplete line before doing so.
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 441
Quoted 3 lines
t/t0030-stripspace.sh +3
-0+ test_cmp expect actual +' +
Is this a recent regression? When applied on top of 'maint' or older, it seems to pass just fine.
... Goes and looks ...
Interesting. Peff's b9605bc4f2 ("config: only read .git/config from configured repos", 2016-09-12) is where this starts failing, which is understandable given the code change to builtin/stripspace.c in [2/3].
The analysis of the log message in [2/3] is wrong and needs updating, though. In the old world order it worked by accident to call git_config() without calling setup_git_directory(); after b9605bc4f2, that no longer is valid and is exposed as a bug.
Your [2/3] is a good fix for that change.
In any case, well spotted.
Quoted 10 lines
t/t0030-stripspace.sh +0
-0test_expect_success 'avoid SP-HT sequence in commented line' ' printf "#\tone\n#\n# two\n" >expect && printf "\tone\n\ntwo\n" | git stripspace -c >actual &&t/t3404-rebase-interactive.sh +0
-0@@ -976,6 +976,18 @@ test_expect_success 'rebase -i respects core.commentchar' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) '
t/t3404-rebase-interactive.sh test_expect_success 'rebase -i respects core.commentchar' ' · line 987
Quoted 10 lines
t/t3404-rebase-interactive.sh +9
-0+test_expect_failure 'rebase -i respects core.commentchar=auto' ' + test_config core.commentchar auto && + write_script copy-edit-script.sh <<-\EOF && + cp "$1" edit-script + EOF + test_set_editor "$(pwd)/copy-edit-script.sh" && + test_when_finished "git rebase --abort || :" && + git rebase -i HEAD^ && + grep "^#" edit-script &&
This was added for debugging that was forgotten?
t/t3404-rebase-interactive.sh test_expect_success 'rebase -i respects core.commentchar' ' · line 988
Quoted 1 line
t/t3404-rebase-interactive.sh +1
-0+ test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)"
This says "There shouldn't be any line left once we remove '#'-commented lines, empty lines and pick insns.". OK.
The correction in [3/3] seems good.
Quoted 5 lines
t/t3404-rebase-interactive.sh +2
-0+' + test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' ' test_when_finished "git branch -D torebase" && git checkout -b torebase branch1 &&
Re: [PATCH 1/3] rebase -i: identify problems with core.commentchar
Quoted 12 lines · Junio C Hamano
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 438
Quoted 4 lines
t/t0030-stripspace.sh +4
-0+test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | git stripspace -c >actual &&We'd want "\n" on this printf to match the one before as well, as this test is not about "does stripspace complete an incomplete line?", I think.
I could amend it while queuing, but I need to know if I am missing a reason why this must be an incomplete line before doing so.
Quoted 6 lines
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 441
Quoted 3 lines
t/t0030-stripspace.sh +3
-0+ test_cmp expect actual +' +Is this a recent regression? When applied on top of 'maint' or older, it seems to pass just fine.
I think we can force failure by running this test somewhere other than the top level of the working tree. A set of proposed amends incoming ...
PATCH 1/3 rebase -i: highlight problems with core.commentchar
From: Johannes Schindelin <[email protected]>
The interactive rebase does not currently play well with core.commentchar. Let's add some tests to highlight those problems that will be fixed in the remainder of the series.
--- t/t0030-stripspace.sh | 9 +++++++++ t/t3404-rebase-interactive.sh | 11 +++++++++++ 2 files changed, 20 insertions(+)
t/t0030-stripspace.sh +9 -0
@@ -432,6 +432,15 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual ' +test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | ( + mkdir sub && cd sub && git stripspace -c + ) >actual && + test_cmp expect actual +' + test_expect_success 'avoid SP-HT sequence in commented line' ' printf "#\tone\n#\n# two\n" >expect && printf "\tone\n\ntwo\n" | git stripspace -c >actual &&
t/t3404-rebase-interactive.sh +11 -0
@@ -983,6 +983,17 @@ test_expect_success 'rebase -i respects core.commentchar' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' +test_expect_failure 'rebase -i respects core.commentchar=auto' ' + test_config core.commentchar auto && + write_script copy-edit-script.sh <<-\EOF && + cp "$1" edit-script + EOF + test_set_editor "$(pwd)/copy-edit-script.sh" && + test_when_finished "git rebase --abort || :" && + git rebase -i HEAD^ && + test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)" +' + test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' ' test_when_finished "git branch -D torebase" && git checkout -b torebase branch1 &&
Signature · 1 line
2.11.0-rc2-154-g95ba452916
PATCH 2/3 stripspace: respect repository config
From: Johannes Schindelin <[email protected]>
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.
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
- #
--- builtin/stripspace.c | 4 +++- t/t0030-stripspace.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
builtin/stripspace.c +3 -1
@@ -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" );
t/t0030-stripspace.sh +1 -1
@@ -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" | (
Signature · 1 line
2.11.0-rc2-154-g95ba452916
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 9 lines · Junio C Hamano
From: Johannes Schindelin <[email protected]>
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.
Quoted 5 lines
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 45 lines
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]>--- builtin/stripspace.c | 4 +++- t/t0030-stripspace.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)builtin/stripspace.c +3
-1@@ -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" );t/t0030-stripspace.sh +1
-1@@ -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" | (
Re: [PATCH 2/3] stripspace: respect repository config
In reply to Junio C HamanoHi Junio,
Quoted 21 lines · Junio C Hamano
From: Johannes Schindelin <[email protected]>
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.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:
Quoted 5 lines
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]>
Thanks for the corrected commit message!
Dscho
PATCH 3/3 rebase -i: handle core.commentChar=auto
In reply to Junio C HamanoFrom: Johannes Schindelin <[email protected]>
When 84c9dc2 (commit: allow core.commentChar=auto for character auto selection, 2014-05-17) extended the core.commentChar functionality to allow for the value 'auto', it forgot that rebase -i was already taught to handle core.commentChar, and in turn forgot to let rebase -i handle that new value gracefully.
Reported by Taufiq Hoven.
--- git-rebase--interactive.sh | 13 +++++++++++-- t/t3404-rebase-interactive.sh | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-)
git-rebase--interactive.sh +11 -2
@@ -93,8 +93,17 @@ eval ' GIT_CHERRY_PICK_HELP="$resolvemsg" export GIT_CHERRY_PICK_HELP -comment_char=$(git config --get core.commentchar 2>/dev/null | cut -c1) -: ${comment_char:=#} +comment_char=$(git config --get core.commentchar 2>/dev/null) +case "$comment_char" in +'' | auto) + comment_char="#" + ;; +?) + ;; +*) + comment_char=$(echo "$comment_char" | cut -c1) + ;; +esac warn () { printf '%s\n' "$*" >&2
t/t3404-rebase-interactive.sh +1 -1
@@ -983,7 +983,7 @@ test_expect_success 'rebase -i respects core.commentchar' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' -test_expect_failure 'rebase -i respects core.commentchar=auto' ' +test_expect_success 'rebase -i respects core.commentchar=auto' ' test_config core.commentchar auto && write_script copy-edit-script.sh <<-\EOF && cp "$1" edit-script
Signature · 1 line
2.11.0-rc2-154-g95ba452916
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
Quoted 7 lines · Junio C Hamano
git-rebase--interactive.sh +1
-2@@ -93,8 +93,17 @@ eval ' GIT_CHERRY_PICK_HELP="$resolvemsg" export GIT_CHERRY_PICK_HELP -comment_char=$(git config --get core.commentchar 2>/dev/null | cut -c1) -: ${comment_char:=#} +comment_char=$(git config --get core.commentchar 2>/dev/null)
git-rebase--interactive.sh eval ' · line 106
Quoted 10 lines
git-rebase--interactive.sh +10
-0+case "$comment_char" in +'' | auto) + comment_char="#" + ;; +?) + ;; +*) + comment_char=$(echo "$comment_char" | cut -c1) + ;; +esac
Amended in is a fix for a typo the other Johannes noticed.
Thanks.
Quoted 13 lines
t/t3404-rebase-interactive.sh +1
-1@@ -983,7 +983,7 @@ test_expect_success 'rebase -i respects core.commentchar' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' -test_expect_failure 'rebase -i respects core.commentchar=auto' ' +test_expect_success 'rebase -i respects core.commentchar=auto' ' test_config core.commentchar auto && write_script copy-edit-script.sh <<-\EOF && cp "$1" edit-script
Re: [PATCH 1/3] rebase -i: highlight problems with core.commentchar
In reply to Junio C HamanoQuoted 9 lines · Junio C Hamano
From: Johannes Schindelin <[email protected]>
The interactive rebase does not currently play well with core.commentchar. Let's add some tests to highlight those problems that will be fixed in the remainder of the series.
Signed-off-by Johannes Schindelin <[email protected]>Signed-off-by Junio C Hamano <[email protected]>---
Sorry, I should have commented here after --- line what changes were proposed by this set of amends.
Quoted 10 lines
t/t0030-stripspace.sh | 9 +++++++++ t/t3404-rebase-interactive.sh | 11 +++++++++++ 2 files changed, 20 insertions(+)t/t0030-stripspace.sh +0
-0@@ -432,6 +432,15 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 442
Quoted 10 lines
t/t0030-stripspace.sh +8
-0' +test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | ( + mkdir sub && cd sub && git stripspace -c + ) >actual && + test_cmp expect actual +'
I noticed that the lack of "\n" at the end was merely copied from the previous existing test (i.e. "-c with with changed comment char"), which was already wrong the same way, so I kept that part as-is.
Running "stripspace" in a subdirectory is to avoid the ".git/config was read without repository discovery as long as the command runs at the top-level of the working tree" accident so that this highlights the breakage with or without Peff's b9605bc4f2 ("config: only read .git/config from configured repos", 2016-09-12).
Quoted 13 lines
t/t0030-stripspace.sh +1
-0+ test_expect_success 'avoid SP-HT sequence in commented line' ' printf "#\tone\n#\n# two\n" >expect && printf "\tone\n\ntwo\n" | git stripspace -c >actual &&t/t3404-rebase-interactive.sh +1
-0@@ -983,6 +983,17 @@ test_expect_success 'rebase -i respects core.commentchar' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' +test_expect_failure 'rebase -i respects core.commentchar=auto' '
t/t3404-rebase-interactive.sh test_expect_success 'rebase -i respects core.commentchar' ' · line 996
Quoted 10 lines
t/t3404-rebase-interactive.sh +10
-0+ test_config core.commentchar auto && + write_script copy-edit-script.sh <<-\EOF && + cp "$1" edit-script + EOF + test_set_editor "$(pwd)/copy-edit-script.sh" && + test_when_finished "git rebase --abort || :" && + git rebase -i HEAD^ && + test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)" +' +
Removed from here is a leftover debugging bit (grep "^#" edit-script).
Re: [PATCH 1/3] rebase -i: highlight problems with core.commentchar
In reply to Junio C HamanoHi Junio,
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 438
Quoted 12 lines · Junio C Hamano
t/t0030-stripspace.sh +4
-0@@ -432,6 +432,15 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual ' +test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | (
Could I ask you to sneak in a \n here?
Thanks,
Dscho
Re: [PATCH 1/3] rebase -i: highlight problems with core.commentchar
Quoted 10 lines · Johannes Schindelin
Quoted 8 lines · Junio C Hamano
t/t0030-stripspace.sh +0
-0@@ -432,6 +432,15 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual '
Quoted 6 lines
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 438
Quoted 4 lines
t/t0030-stripspace.sh +4
-0+test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | (Could I ask you to sneak in a \n here?
The one before that _is_ about fixing incomplete line, but this and the one before this one are not, so I think we should fix them at the same time.
But does it break anything to leave it as-is? If not, I'd prefer to leave this (and one before this one) for a later clean-up patch post release.
Thanks
Re: [PATCH 1/3] rebase -i: highlight problems with core.commentchar
Hi Junio,
Quoted 19 lines · Junio C Hamano
Quoted 10 lines · Johannes Schindelin
Quoted 8 lines · Junio C Hamano
t/t0030-stripspace.sh +0
-0@@ -432,6 +432,15 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual 'Quoted 6 lines
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 438
Quoted 4 lines
t/t0030-stripspace.sh +4
-0+test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | (Could I ask you to sneak in a \n here?
Quoted 7 lines
The one before that _is_ about fixing incomplete line, but this and the one before this one are not, so I think we should fix them at the same time.
But does it break anything to leave it as-is? If not, I'd prefer to leave this (and one before this one) for a later clean-up patch post release.
Fair enough.
As a matter of fact, we do not even need to change it later. If it ain't broke, don't fix it.
Ciao,
Dscho
Re: [PATCH 1/3] rebase -i: identify problems with core.commentchar
In reply to Junio C HamanoQuoted 14 lines · Junio C Hamano
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 441
Quoted 3 lines
t/t0030-stripspace.sh +3
-0+ test_cmp expect actual +' +Is this a recent regression? When applied on top of 'maint' or older, it seems to pass just fine.
... Goes and looks ...Interesting. Peff's
b9605bc4f2("config: only read .git/config from configured repos", 2016-09-12) is where this starts failing, which is understandable given the code change tobuiltin/stripspace.cin [2/3].
Quoted 4 lines
The analysis of the log message in [2/3] is wrong and needs updating, though. In the old world order it worked by accident to call
git_config()without callingsetup_git_directory(); afterb9605bc4f2, that no longer is valid and is exposed as a bug.
Yeah, I noticed that while reading the patch. My b9605bc4f2 did regress this case, but called out the fact that "cd subdir && git stripspace" would never have worked. So one step back, 2 steps forward, and Dscho's patch is the right step forward.
-Peff
Re: [PATCH 1/3] rebase -i: identify problems with core.commentchar
Quoted 21 lines · Jeff King
Quoted 14 lines · Junio C Hamano
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 441
Quoted 3 lines
t/t0030-stripspace.sh +3
-0+ test_cmp expect actual +' +Is this a recent regression? When applied on top of 'maint' or older, it seems to pass just fine.
... Goes and looks ...Interesting. Peff's
b9605bc4f2("config: only read .git/config from configured repos", 2016-09-12) is where this starts failing, which is understandable given the code change tobuiltin/stripspace.cin [2/3].Quoted 4 lines
The analysis of the log message in [2/3] is wrong and needs updating, though. In the old world order it worked by accident to call
git_config()without callingsetup_git_directory(); afterb9605bc4f2, that no longer is valid and is exposed as a bug.
Quoted 4 lines
Yeah, I noticed that while reading the patch. My
b9605bc4f2did regress this case, but called out the fact that "cd subdir && git stripspace" would never have worked. So one step back, 2 steps forward, and Dscho's patch is the right step forward.
Yes, absolutely.
I sent out a set of proposed amends, and the one for this step 1/3 runs the command inside a subdirectory to force it not to find the .git/config file relative to its pwd, which can reveal the existing breakage without help by b9605bc4f2 ;-) hence can be forked for older maintenance tracks.
Re: [PATCH 1/3] rebase -i: identify problems with core.commentchar
Quoted 5 lines · Junio C Hamano
Quoted 4 lines
Yeah, I noticed that while reading the patch. My
b9605bc4f2did regress this case, but called out the fact that "cd subdir && git stripspace" would never have worked. So one step back, 2 steps forward, and Dscho's patch is the right step forward.
Quoted 7 lines
Yes, absolutely.
I sent out a set of proposed amends, and the one for this step 1/3 runs the command inside a subdirectory to force it not to find the .git/config file relative to its pwd, which can reveal the existing breakage without help by
b9605bc4f2;-) hence can be forked for older maintenance tracks.
Makes sense, and your amended patch looks good.
-Peff
Re: [PATCH 1/3] rebase -i: identify problems with core.commentchar
In reply to Junio C HamanoHi Junio,
Quoted 10 lines · Junio C Hamano
Quoted 8 lines · Johannes Schindelin
t/t0030-stripspace.sh +0
-0@@ -432,6 +432,13 @@ test_expect_success '-c with changed comment char' ' test_cmp expect actual '
Quoted 6 lines
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' ' · line 438
Quoted 4 lines
t/t0030-stripspace.sh +4
-0+test_expect_failure '-c with comment char defined in .git/config' ' + test_config core.commentchar = && + printf "= foo\n" >expect && + printf "foo" | git stripspace -c >actual &&We'd want "\n" on this printf to match the one before as well,
True.
Quoted 2 lines
The analysis of the log message in [2/3] is wrong and needs updating, though.
Thanks for following up on that, and for fixing the commit message.
Quoted 11 lines
t/t0030-stripspace.sh test_expect_success '-c with changed comment char' '
Quoted 9 lines
t/t0030-stripspace.sh +9
-0+test_expect_failure 'rebase -i respects core.commentchar=auto' ' + test_config core.commentchar auto && + write_script copy-edit-script.sh <<-\EOF && + cp "$1" edit-script + EOF + test_set_editor "$(pwd)/copy-edit-script.sh" && + test_when_finished "git rebase --abort || :" && + git rebase -i HEAD^ && + grep "^#" edit-script &&This was added for debugging that was forgotten?
No, this was me trying to ensure that the comment character '#' *is* used. As opposed to somehow testing any edit script that contains no commented lines whatsoever.
But if you don't care, I won't, either.
Ciao,
Dscho
PATCH 2/3 stripspace: respect repository config
In reply to Johannes SchindelinWhen eff80a9 (Allow custom "comment char", 2013-01-16) taught the stripspace command to respect the config setting core.commentChar, it forgot that this variable may be defined in .git/config.
So 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
- #
--- builtin/stripspace.c | 4 +++- t/t0030-stripspace.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
builtin/stripspace.c +3 -1
@@ -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" );
t/t0030-stripspace.sh +1 -1
@@ -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" | git stripspace -c >actual &&
Signature · 1 line
2.10.1.583.g721a9e0
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 23 lines · Johannes Schindelin
When eff80a9 (Allow custom "comment char", 2013-01-16) taught the
stripspacecommand to respect the config settingcore.commentChar, it forgot that this variable may be defined in .git/config.So 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]>--- builtin/stripspace.c | 4 +++- t/t0030-stripspace.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)builtin/stripspace.c +0
-0
builtin/stripspace.c int cmd_stripspace(int argc, const char **argv, const char *prefix) · line 50
Quoted 8 lines
builtin/stripspace.c +3
-1@@ -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 ); + }
This conditional config file reading is a trap for similar bugs to happen again. Is there any reason we should not just mark the command RUN_SETUP_GENTLY in git.c and call git_config() here unconditionally?
Quoted 3 lines
builtin/stripspace.c +0
-0if (strbuf_read (&buf,0 ,1024 ) <0 )die_errno ("could not read the input" );
Signature · 1 line
Duy
Re: [PATCH 2/3] stripspace: respect repository config
Hi Duy,
Quoted 28 lines · Duy Nguyen
Quoted 26 lines · Johannes Schindelin
When eff80a9 (Allow custom "comment char", 2013-01-16) taught the
stripspacecommand to respect the config settingcore.commentChar, it forgot that this variable may be defined in .git/config.So 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]>--- builtin/stripspace.c | 4 +++- t/t0030-stripspace.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)builtin/stripspace.c +0
-0@@ -44,8 +44,10 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)if (argc)usage_with_options (stripspace_usage, options);
Quoted 9 lines
builtin/stripspace.c int cmd_stripspace(int argc, const char **argv, const char *prefix) · line 50
Quoted 5 lines
builtin/stripspace.c +3
-1-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 ); + }This conditional config file reading is a trap for similar bugs to happen again. Is there any reason we should not just mark the command
RUN_SETUP_GENTLYingit.cand callgit_config()here unconditionally?
As I plan to slip these patches into Git for Windows v2.11.0, i.e. making this a last-minute hot fix, I want to err on the side of caution. So I'd rather keep this conditional (it might regress on the performance front, or something).
Ciao,
Dscho
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 6 lines · Johannes Schindelin
Quoted 3 lines
This conditional config file reading is a trap for similar bugs to happen again. Is there any reason we should not just mark the command
RUN_SETUP_GENTLYingit.cand callgit_config()here unconditionally?As I plan to slip these patches into Git for Windows v2.11.0, i.e. making this a last-minute hot fix, I want to err on the side of caution.
So do I. As a hot-fix, I'd prefer the patch I queued yesterday.
I think we want to audit the ones without RUN_SETUP* in the command table in order to hunt for regression aka "a fix revealed a bug that was covered by .git/config accidentally getting read when run from the top-level of the working tree", though. We may find unreported breakages that we may have to fix.
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 5 lines · Junio C Hamano
I think we want to audit the ones without RUN_SETUP* in the command table in order to hunt for regression aka "a fix revealed a bug that was covered by .git/config accidentally getting read when run from the top-level of the working tree", though. We may find unreported breakages that we may have to fix.
So I took a brief look at the "PROGRAM_OBJS += ..." in the Makefile for non-builtin commands, and commands[] array in git.c for builtin commands to see how bad it looks.
Archive & Upload-archive:
"cd Documentation && git archive --remote=origin" immediately hits "BUG: setup_git_env called without repository" if your Git is built with b1ef400eec ("setup_git_env: avoid blind fall-back to ".git"", 2016-10-20), which will not be part of the upcoming release. And 'origin' will probably not be understood from the local config.
I think we can do the "gently" thing there, as we may be retrieving a remote archive outside a local repository. We'd need to tweak "output" with prefix to compensate for the case in which the command is run from a subdirectory, and probably we need to futz with the setup_prefix parameter to write_archive(), as a local caller now will know if we are in nongit situation.
On the upload-archive side that serves "--remote" request, there is enter_repo() so we should be covered OK.
Mailinfo:
We may want a "gently" thing there to pick up local configuration. i18n.commitencoding and mailinfo.scissors in local repository would be ignored otherwise.
Splitspace:
Dscho fixed this one.
Verify-pack:
This calls git_config() but these days farms out its operation to "index-pack", so we should be OK. We may even want to lose the call to git_config() which does not affect anything.
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 7 lines · Junio C Hamano
Archive & Upload-archive:
"cd Documentation && git archive --remote=origin" immediately hits "BUG:
setup_git_envcalled without repository" if your Git is built withb1ef400eec("setup_git_env: avoid blind fall-back to ".git"", 2016-10-20), which will not be part of the upcoming release. And 'origin' will probably not be understood from the local config.
Yeah, I think "cd Documentation && git archive --remote" has always been broken. It doesn't barf until b1ef400eec, but yes, v2.11-rc2 breaks finding "origin" in the local config.
I agree that doing the "gently" setup will fix the config problem, but there's more to do to make it work with b1ef400eec outside of a repo. It looks like read_remotes_file() and read_branches_file() in remote.c need to learn to silently return when we are not in a git repository (or alternatively, remote_get_1() should learn not to call them in such a case).
I doubt this is a critical case (it only kicks in if you are outside a repo _and_ your name looks like a remote name and not a URL, _and_ it is not defined by your config, and the result is that we die("BUG") rather than reporting "you don't have such a remote"). But any time it is possible to hit a die("BUG"), we should be fixing it.
Quoted 6 lines
I think we can do the "gently" thing there, as we may be retrieving a remote archive outside a local repository. We'd need to tweak "output" with prefix to compensate for the case in which the command is run from a subdirectory, and probably we need to futz with the
setup_prefixparameter towrite_archive(), as a local caller now will know if we are in nongit situation.
Makes sense. I think OPT_FILENAME() would handle "output", but yeah, it looks like write_archive() already tries to be clever about the setup.
Quoted 2 lines
On the upload-archive side that serves "--remote" request, there is
enter_repo()so we should be covered OK.
Right, that has to run in a repo, and enter_repo() should handle it.
Quoted 5 lines
Mailinfo:
We may want a "gently" thing there to pick up local configuration. i18n.commitencoding and mailinfo.scissors in local repository would be ignored otherwise.
Yeah, agreed.
Quoted 5 lines
Verify-pack:
This calls
git_config()but these days farms out its operation to "index-pack", so we should be OK. We may even want to lose the call togit_config()which does not affect anything.
I'd be slightly worried that there is a core.* config option that affects us in a subtle way (e.g., some portability flag for how we do run_command()). I don't think there is one now, but it seems like a potential maintenance pitfall. IOW, I think I'd generally prefer to err on the side of having everything do a gentle setup and load at least the default config, to avoid surprises.
I don't think it's a high priority, though.
So what do you want to do for v2.11? I think there are minor regressions in stripspace, archive, and mailinfo with respect to reading .git/config. The right solution in each case is to do a gentle repo setup. We have patches for stripspace already, but not yet for the other two. They _should_ be fairly trivial, but we are getting awfully close to the release. Do you want to do another round of -rc3? Ship with the minor regressions and fix them up in v2.11.1? Last-minute revert the original config topic that introduced the regressions (I'm biased against that as the author, but I also think it's dangerous; it's a big enough topic that it might introduce new problems)?
-Peff
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 6 lines · Jeff King
So what do you want to do for v2.11? I think there are minor regressions in stripspace, archive, and mailinfo with respect to reading .git/config. The right solution in each case is to do a gentle repo setup. We have patches for stripspace already, but not yet for the other two. They _should_ be fairly trivial, but we are getting awfully close to the release.
Right.
Quoted 2 lines
Do you want to do another round of -rc3? Ship with the minor regressions and fix them up in v2.11.1?
I am leaning towards the former (though we may also end up doing the latter).
Here is an initial attempt. It turns out that write_archive() must be callable outside a repository to respond to "git archive --list", which happens in parse_archive_args(), and the "have-repository?" check cannot be moved before that to the caller.
No tests yet. Help appreciated ;-)
archive.c | 9 ++------- archive.h | 2 +- builtin/archive.c | 6 +++--- builtin/upload-archive.c | 2 +- git.c | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-)
archive.c +2 -7
@@ -504,15 +504,11 @@ static int parse_archive_args(int argc, const char **argv, }int write_archive (int argc,const char **argv,const char *prefix, -int setup_prefix,const char *name_hint,int remote) +const char *name_hint,int remote) { -int nongit =0 ;const struct archiver *ar =NULL ;struct archiver_args args; -if (setup_prefix && prefix ==NULL ) - prefix =setup_git_directory_gently (&nongit); -git_config_get_bool ("uploadarchive.allowunreachable" , &remote_allow_unreachable);git_config (git_default_config,NULL );
@@ -520,7 +516,7 @@ int write_archive(int argc, const char **argv, const char *prefix,init_zip_archiver (); argc =parse_archive_args (argc, argv, &ar, &args, name_hint, remote); -if (nongit) { +if (!startup_info->have_repository) {/* * We know this will die() with an error, so we could just * die ourselves; but its error message will be more specific
@@ -528,7 +524,6 @@ int write_archive(int argc, const char **argv, const char *prefix,*/ setup_git_directory (); } -parse_treeish_arg (argv, &args, prefix, remote);parse_pathspec_arg (argv +1 , &args);
archive.h +1 -1
@@ -36,7 +36,7 @@ typedef int (*write_archive_entry_fn_t)(struct archiver_args *args, unsigned int mode);extern int write_archive_entries (struct archiver_args *args,write_archive_entry_fn_t write_entry); -extern int write_archive (int argc,const char **argv,const char *prefix,int setup_prefix,const char *name_hint,int remote); +extern int write_archive (int argc,const char **argv,const char *prefix,const char *name_hint,int remote);const char *archive_format_from_filename (const char *filename); extern void *sha1_file_to_archive(const struct archiver_args *args,
builtin/archive.c +3 -3
@@ -85,8 +85,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)const char *output =NULL ;const char *remote =NULL ;struct option local_opts[] = { -OPT_STRING ('o' ,"output" , &output,N_ ("file" ), -N_ ("write the archive to this file" )), +OPT_FILENAME ('o' ,"output" , &output, +N_ ("write the archive to this file" )),OPT_STRING (0 ,"remote" , &remote,N_ ("repo" ),N_ ("retrieve the archive from remote repository <repo>" )), OPT_STRING(0, "exec", &exec, N_("command"),
@@ -105,5 +105,5 @@ int cmd_archive(int argc, const char **argv, const char *prefix)setvbuf (stderr,NULL , _IOLBF,BUFSIZ ); -return write_archive (argc, argv, prefix,1 , output,0 ); +return write_archive (argc, argv, prefix, output,0 ); }
builtin/upload-archive.c +1 -1
@@ -43,7 +43,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix) }/* parse all options sent by the client */ -return write_archive (sent_argv.argc, sent_argv.argv, prefix,0 ,NULL ,1 ); +return write_archive (sent_argv.argc, sent_argv.argv, prefix,NULL ,1 ); } __attribute__((format (printf, 1, 2)))
git.c +2 -2
@@ -396,7 +396,7 @@ static struct cmd_struct commands[] = { { "am", cmd_am, RUN_SETUP | NEED_WORK_TREE }, { "annotate", cmd_annotate, RUN_SETUP }, { "apply", cmd_apply, RUN_SETUP_GENTLY }, - { "archive", cmd_archive }, + { "archive", cmd_archive, RUN_SETUP_GENTLY }, { "bisect--helper", cmd_bisect__helper, RUN_SETUP }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP },
@@ -445,7 +445,7 @@ static struct cmd_struct commands[] = { { "ls-files", cmd_ls_files, RUN_SETUP | SUPPORT_SUPER_PREFIX }, { "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY }, { "ls-tree", cmd_ls_tree, RUN_SETUP }, - { "mailinfo", cmd_mailinfo }, + { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY }, { "mailsplit", cmd_mailsplit }, { "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE }, { "merge-base", cmd_merge_base, RUN_SETUP },
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 5 lines · Junio C Hamano
Quoted 2 lines
Do you want to do another round of -rc3? Ship with the minor regressions and fix them up in v2.11.1?
I am leaning towards the former (though we may also end up doing the latter).
I think I'd lead towards -rc3, as well. Our schedule is somewhat arbitrary anyway, and one week is less important than somebody picking up the new release and trying to puzzle out a regression that we already have a fix for.
Quoted 4 lines
Here is an initial attempt. It turns out that
write_archive()must be callable outside a repository to respond to "git archive --list", which happens inparse_archive_args(), and the "have-repository?" check cannot be moved before that to the caller.
Right, that makes sense. t5000 already tests git-archive outside of a repo, although it does it in a funny way (it sets GIT_DIR rather than relying on GIT_CEILING_DIRECTORIES). We should cover that and make sure that --remote works outside of a repo. Those work now, but we want to make sure we don't regress them.
And then we want to test that --remote can read a configured remote name.
And then post-v2.11, we'd want to check that --remote=foo outside of a repo produces a sane error instead of looking for a bogus $GIT_DIR/remotes/foo.
Something like this, which does all but the last (and that should probably happen separately post-release).
---
t/t5000-tar-tree.sh +29 -3
@@ -94,6 +94,20 @@ check_tar() { ' } +# run "$@" inside a non-git directory +nongit () { + test -d non-repo || + mkdir non-repo || + return 1 + + ( + GIT_CEILING_DIRECTORIES=$(pwd) && + export GIT_CEILING_DIRECTORIES && + cd non-repo && + "$@" + ) +} + test_expect_success \ 'populate workdir' \ 'mkdir a &&
@@ -179,6 +193,12 @@ test_expect_success 'git archive --remote' \ 'git archive --remote=. HEAD >b5.tar && test_cmp_bin b.tar b5.tar' +test_expect_success 'git archive --remote with configured remote' ' + git config remote.foo.url . && + git archive --remote=foo HEAD >b5-nick.tar && + test_cmp_bin b.tar b5-nick.tar +' + test_expect_success \ 'validate file modification time' \ 'mkdir extract &&
@@ -197,9 +217,15 @@ test_expect_success 'git archive with --output, override inferred format' ' test_cmp_bin b.tar d4.zip ' -test_expect_success \ - 'git archive --list outside of a git repo' \ - 'GIT_DIR=some/non-existing/directory git archive --list' +test_expect_success 'git archive --list outside of a git repo' ' + nongit git archive --list +' + +test_expect_success 'git archive --remote outside of a git repo' ' + git archive HEAD >expect.tar && + nongit git archive --remote="$PWD" HEAD >actual.tar && + test_cmp_bin expect.tar actual.tar +' test_expect_success 'clients cannot access unreachable commits' ' test_commit unreachable &&
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 5 lines · Jeff King
Quoted 3 lines · Junio C Hamano
Quoted 2 lines
Do you want to do another round of -rc3? Ship with the minor regressions and fix them up in v2.11.1?
Quoted 7 lines
Quoted 2 lines
I am leaning towards the former (though we may also end up doing the latter).
I think I'd lead towards -rc3, as well. Our schedule is somewhat arbitrary anyway, and one week is less important than somebody picking up the new release and trying to puzzle out a regression that we already have a fix for.
OK. The "mailinfo" part turns out a bit more than RUN_SETUP_GENTLY as it takes paths from the command line that needs to be adjusted for the prefix.
-- >8 --
From: Junio C Hamano <[email protected]>
Date: Tue, 22 Nov 2016 13:13:16 -0800
Subject: [PATCH] mailinfo: read local configuration
Since b9605bc4f2 ("config: only read .git/config from configured repos", 2016-09-12), we do not read from ".git/config" unless we know we are in a repository. "git mailinfo" however didn't do the repository discovery and instead relied on the old behaviour. This was mostly OK because it was merely run as a helper program by other porcelain scripts that first chdir's up to the root of the working tree.
Teach the command to run a "gentle" version of repository discovery so that local configuration variables like mailinfo.scissors are honoured.
--- builtin/mailinfo.c | 19 +++++++++++++++---- git.c | 2 +- t/t5100-mailinfo.sh | 13 +++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-)
builtin/mailinfo.c +15 -4
@@ -11,15 +11,20 @@static const char mailinfo_usage[] ="git mailinfo [-k | -b] [-m | --message-id] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] <msg> <patch> < mail >info" ; +static char *prefix_copy (const char *prefix,const char *filename) +{ +if (!prefix ||is_absolute_path (filename)) +return xstrdup (filename); +return xstrdup (prefix_filename (prefix,strlen (prefix), filename)); +} +int cmd_mailinfo (int argc,const char **argv,const char *prefix) {const char *def_charset;struct mailinfo mi;int status; +char *msgfile, *patchfile; -/* NEEDSWORK: might want to do the optional .git/ directory -* discovery -*/ setup_mailinfo (&mi); def_charset =get_commit_output_encoding ();
@@ -54,8 +59,14 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix) mi.input = stdin; mi.output = stdout; - status = !!mailinfo (&mi, argv[1 ], argv[2 ]); + + msgfile =prefix_copy (prefix, argv[1 ]); + patchfile =prefix_copy (prefix, argv[2 ]); + + status = !!mailinfo (&mi, msgfile, patchfile);clear_mailinfo (&mi); +free (msgfile); +free (patchfile);return status; }
git.c +1 -1
@@ -445,7 +445,7 @@ static struct cmd_struct commands[] = { { "ls-files", cmd_ls_files, RUN_SETUP | SUPPORT_SUPER_PREFIX }, { "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY }, { "ls-tree", cmd_ls_tree, RUN_SETUP }, - { "mailinfo", cmd_mailinfo }, + { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY }, { "mailsplit", cmd_mailsplit }, { "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE }, { "merge-base", cmd_merge_base, RUN_SETUP },
t/t5100-mailinfo.sh +13 -0
@@ -158,4 +158,17 @@ test_expect_success 'mailinfo handles rfc2822 comment' ' test_cmp "$DATA/comment.expect" comment/info ' +test_expect_success 'mailinfo with mailinfo.scissors config' ' + test_config mailinfo.scissors true && + ( + mkdir sub && + cd sub && + git mailinfo ../msg0014.sc ../patch0014.sc <../0014 >../info0014.sc + ) && + test_cmp "$DATA/msg0014--scissors" msg0014.sc && + test_cmp "$DATA/patch0014--scissors" patch0014.sc && + test_cmp "$DATA/info0014--scissors" info0014.sc +' + + test_done
Signature · 1 line
2.11.0-rc2-170-g4c384f318f
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 3 lines · Junio C Hamano
OK. The "mailinfo" part turns out a bit more than
RUN_SETUP_GENTLYas it takes paths from the command line that needs to be adjusted for the prefix.
I wondered at first if our lack of parse-options here was holding us back from using OPT_FILENAME. Though even if that was the case, it is probably better to do the minimal fix in this instance, rather than converting the option parsing.
However, the paths which need munged are not even options, they are arguments. So we wouldn't be able to rely on OPT_FILENAME anyway. I'm surprised we haven't had to deal with this elsewhere, but I guess most commands don't take arbitrary filenames (things like add take pathspecs, and then the pathspec machinery takes care of the details).
The only other case I could think of is git-apply, and it does use prefix_filename() correctly.
builtin/mailinfo.c line 19
Quoted 6 lines
builtin/mailinfo.c +6
-0+static char *prefix_copy (const char *prefix,const char *filename) +{ +if (!prefix ||is_absolute_path (filename)) +return xstrdup (filename); +return xstrdup (prefix_filename (prefix,strlen (prefix), filename)); +}
So this is more or less a copy of parse-option's fix_filename(), which makes sense.
I noticed that git-apply does not check is_absolute_path(), but that's OK, as prefix_filename() does. So I think it would be correct to drop it here, but it doesn't matter much either way.
builtin/mailinfo.c line 28
Quoted 11 lines
int
cmd_mailinfo(int argc, const char **argv, const char *prefix){builtin/mailinfo.c +1
-3const char *def_charset;struct mailinfo mi;int status; +char *msgfile, *patchfile; -/* NEEDSWORK: might want to do the optional .git/ directory -* discovery -*/ setup_mailinfo (&mi);
This part looks straightforward and correct. Dropping the NEEDSWORK is a nice bonus.
t/t5100-mailinfo.sh test_expect_success 'mailinfo handles rfc2822 comment' ' · line 171
Quoted 11 lines
t/t5100-mailinfo.sh +11
-0+test_expect_success 'mailinfo with mailinfo.scissors config' ' + test_config mailinfo.scissors true && + ( + mkdir sub && + cd sub && + git mailinfo ../msg0014.sc ../patch0014.sc <../0014 >../info0014.sc + ) && + test_cmp "$DATA/msg0014--scissors" msg0014.sc && + test_cmp "$DATA/patch0014--scissors" patch0014.sc && + test_cmp "$DATA/info0014--scissors" info0014.sc +'
And this test makes sense. Even without "sub", it would show the regression, but it's a good idea to test the sub-directory case to cover the path-munging.
In the "archive --remote" test I added, we may want to do the same to show that "--output" points at the correct path.
-Peff
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 7 lines · Jeff King
Quoted 7 lines
(quoted diff) +7
-0+test_expect_success 'mailinfo with mailinfo.scissors config' ' + test_config mailinfo.scissors true && + ( + mkdir sub && + cd sub && + git mailinfo ../msg0014.sc ../patch0014.sc <../0014 >../info0014.sc + ) &&
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ test_cmp "$DATA/msg0014--scissors" msg0014.sc && + test_cmp "$DATA/patch0014--scissors" patch0014.sc && + test_cmp "$DATA/info0014--scissors" info0014.sc +'And this test makes sense. Even without "sub", it would show the regression, but it's a good idea to test the sub-directory case to cover the path-munging.
Yup. Obviously during my initial attempt I was scratching my head wondering where these two files went--they were later found inside t/ directory which was really bad ;-)
Quoted 2 lines
In the "archive --remote" test I added, we may want to do the same to show that "--output" points at the correct path.
Perhaps something like this. By going down one level, we make sure that it is not sufficient to accidentally read from .git/config to find out what 'foo' is, and also ../b5-nick.tar that is relative to the prefix (aka 'a/') ends up at the top-level.
t/t5000-tar-tree.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
t/t5000-tar-tree.sh +4 -1
@@ -195,7 +195,10 @@ test_expect_success 'git archive --remote' \ test_expect_success 'git archive --remote with configured remote' ' git config remote.foo.url . && - git archive --remote=foo HEAD >b5-nick.tar && + ( + cd a && + git archive --remote=foo --output=../b5-nick.tar HEAD + ) && test_cmp_bin b.tar b5-nick.tar '
Re: [PATCH 2/3] stripspace: respect repository config
Quoted 7 lines · Junio C Hamano
Quoted 3 lines
And this test makes sense. Even without "sub", it would show the regression, but it's a good idea to test the sub-directory case to cover the path-munging.
Yup. Obviously during my initial attempt I was scratching my head wondering where these two files went--they were later found inside t/ directory which was really bad ;-)
Heh. Yeah, it's nice when the failure mode doesn't escape the trash directory, but it's probably not worth worrying about too much.
Quoted 7 lines
Quoted 2 lines
In the "archive --remote" test I added, we may want to do the same to show that "--output" points at the correct path.
Perhaps something like this. By going down one level, we make sure that it is not sufficient to accidentally read from .git/config to find out what 'foo' is, and also ../b5-nick.tar that is relative to the prefix (aka 'a/') ends up at the top-level.
Yeah, your modification looks good.
-Peff
Re: [PATCH 2/3] stripspace: respect repository config
In reply to Jeff KingQuoted 7 lines · Jeff King
Quoted 5 lines
Quoted 2 lines
Do you want to do another round of -rc3? Ship with the minor regressions and fix them up in v2.11.1?
I am leaning towards the former (though we may also end up doing the latter).
I think I'd lead towards -rc3, as well. Our schedule is somewhat
I meant s/lead/lean/, of course.
Quoted 2 lines
Something like this, which does all but the last (and that should probably happen separately post-release).
As usual, I'm utterly confused by the $(pwd) versus $PWD thing. So let me review what I did to see if it makes sense. :)
t/t5000-tar-tree.sh check_tar() { · line 109
Quoted 13 lines
t/t5000-tar-tree.sh +13
-0+# run "$@" inside a non-git directory +nongit () { + test -d non-repo || + mkdir non-repo || + return 1 + + ( + GIT_CEILING_DIRECTORIES=$(pwd) && + export GIT_CEILING_DIRECTORIES && + cd non-repo && + "$@" + ) +}
I copied this bit from t1515, which sets up a similar scenario. I think it _probably_ works either way because of the environment-variable conversion magic that Windows bash does.
t/t5000-tar-tree.sh test_expect_success 'git archive with --output, override inferred format' ' · line 228
Quoted 5 lines
t/t5000-tar-tree.sh +5
-0+test_expect_success 'git archive --remote outside of a git repo' ' + git archive HEAD >expect.tar && + nongit git archive --remote="$PWD" HEAD >actual.tar && + test_cmp_bin expect.tar actual.tar +'
I'm not sure if it matters here. I almost wrote $TRASH_DIRECTORY, but that I think is in the same form as $PWD. Either would be fine.
-Peff
PATCH 3/3 rebase -i: handle core.commentChar=auto
In reply to Johannes SchindelinWhen 84c9dc2 (commit: allow core.commentChar=auto for character auto selection, 2014-05-17) extended the core.commentChar functionality to allow for the value 'auto', it forgot that rebase -i was already taught to handle core.commentChar, and in turn forgot to let rebase -i handle that new value gracefully.
Reported by Taufiq Hoven.
--- git-rebase--interactive.sh | 13 +++++++++++-- t/t3404-rebase-interactive.sh | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-)
git-rebase--interactive.sh +11 -2
@@ -93,8 +93,17 @@ eval ' GIT_CHERRY_PICK_HELP="$resolvemsg" export GIT_CHERRY_PICK_HELP -comment_char=$(git config --get core.commentchar 2>/dev/null | cut -c1) -: ${comment_char:=#} +comment_char=$(git config --get core.commentchar 2>/dev/null) +case "$comment_char" in +''|auto) + comment_char=# + ;; +?) + ;; +*) + comment_char=$(comment_char | cut -c1) + ;; +esac warn () { printf '%s\n' "$*" >&2
t/t3404-rebase-interactive.sh +1 -1
@@ -976,7 +976,7 @@ test_expect_success 'rebase -i respects core.commentchar' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' -test_expect_failure 'rebase -i respects core.commentchar=auto' ' +test_expect_success 'rebase -i respects core.commentchar=auto' ' test_config core.commentchar auto && write_script copy-edit-script.sh <<-\EOF && cp "$1" edit-script
Signature · 1 line
2.10.1.583.g721a9e0
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
Am 21.11.2016 um 15:18 schrieb Johannes Schindelin:
git-rebase--interactive.sh eval ' · line 104
Quoted 11 lines
git-rebase--interactive.sh +9
-2-comment_char=$(git config --get core.commentchar 2>/dev/null | cut -c1) -: ${comment_char:=#} +comment_char=$(git config --get core.commentchar 2>/dev/null) +case "$comment_char" in +''|auto) + comment_char=# + ;; +?) + ;; +*) + comment_char=$(comment_char | cut -c1)
comment_char is a command? Did you mean
comment_char=$(echo "$comment_char" | cut -c1)
It could be written without forking a process:
comment_char=${comment_char%${comment_char#?}}(aka "remove from the end what remains after removing the first character")
-- Hannes
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
Quoted 3 lines · Johannes Sixt
comment_charis a command? Did you meancomment_char=$(echo "$comment_char" | cut -c1)
;-)
Quoted 5 lines
It could be written without forking a process:
comment_char=${comment_char%${comment_char#?}}(aka "remove from the end what remains after removing the first character")
Hopefully nobody would include any glob metacharacters in there, e.g. "core.commentchar='=*'", which would break that?
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
Am 21.11.2016 um 19:40 schrieb Junio C Hamano:
Quoted 9 lines
Quoted 5 lines · Johannes Sixt
It could be written without forking a process:
comment_char=${comment_char%${comment_char#?}}(aka "remove from the end what remains after removing the first character")
Hopefully nobody would include any glob metacharacters in there, e.g. "core.commentchar='=*'", which would break that?
Heh. I tested a few variations, but not this one. Make it
comment_char=${comment_char%"${comment_char#?}"}
;)
-- Hannes
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
Quoted 6 lines · Johannes Sixt
Am 21.11.2016 um 19:40 schrieb Junio C Hamano:
Quoted 5 lines
Quoted 4 lines · Johannes Sixt
It could be written without forking a process:
comment_char=${comment_char%${comment_char#?}}
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
(aka "remove from the end what remains after removing the first character")
Hopefully nobody would include any glob metacharacters in there, e.g. "core.commentchar='=*'", which would break that?
Heh. I tested a few variations, but not this one. Make it
comment_char=${comment_char%"${comment_char#?}"}
I tried a few implementations of shells, and decided that this is not worth the portability hassle.
Setting comment-char to multi-letter sequence is not supported at all, and this code is protecting itself from that nonsense---it does not need to be fast, and Dscho already gives a fast path for a single letter case in his patch.
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
Am 21.11.2016 um 20:07 schrieb Junio C Hamano:
Quoted 4 lines
Setting comment-char to multi-letter sequence is not supported at all, and this code is protecting itself from that nonsense---it does not need to be fast, and Dscho already gives a fast path for a single letter case in his patch.
Fair enough, no problem.
-- Hannes
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
In reply to Johannes SixtHi Hannes,
Quoted 15 lines · Johannes Sixt
Am 21.11.2016 um 15:18 schrieb Johannes Schindelin:
git-rebase--interactive.sh eval ' · line 104
Quoted 11 lines
git-rebase--interactive.sh +9
-2-comment_char=$(git config --get core.commentchar 2>/dev/null | cut -c1) -: ${comment_char:=#} +comment_char=$(git config --get core.commentchar 2>/dev/null) +case "$comment_char" in +''|auto) + comment_char=# + ;; +?) + ;; +*) + comment_char=$(comment_char | cut -c1)
comment_charis a command? Did you mean
Quoted 1 line
comment_char=$(echo "$comment_char" | cut -c1)
D'oh.
Quoted 5 lines
It could be written without forking a process:
comment_char=${comment_char%${comment_char#?}}(aka "remove from the end what remains after removing the first character")
I was considering this, actually, but it is rather unreadable. Better rewrite it in C, to begin with.
Thanks,
Dscho
Re: [PATCH 3/3] rebase -i: handle core.commentChar=auto
In reply to Johannes SchindelinQuoted 4 lines · Johannes Schindelin
When 84c9dc2 (commit: allow core.commentChar=auto for character auto selection, 2014-05-17) extended the core.commentChar functionality to allow for the value 'auto', it forgot that rebase -i was already taught to handle core.commentChar,
I think this is 180bad3 (rebase -i: respect core.commentchar - 2013-02-11) and a couple followup fixes. My bad.
Quoted 4 lines
and in turn forgot to let rebase -i handle that
new value gracefully.Reported by Taufiq Hoven.
Another report in the same area: a merge conflict always writes the "Conflicts:" section in the commit message with '#' as comment char when core.commentChar is auto. I've known this for a while, but it has not bitten me hard enough to do something about it,
Quoted 12 lines
Signed-off-by Johannes Schindelin <[email protected]>--- git-rebase--interactive.sh | 13 +++++++++++-- t/t3404-rebase-interactive.sh | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-)git-rebase--interactive.sh +0
-0
git-rebase--interactive.sh eval ' · line 99
Quoted 9 lines
git-rebase--interactive.sh +4
-2@@ -93,8 +93,17 @@ eval ' GIT_CHERRY_PICK_HELP="$resolvemsg" export GIT_CHERRY_PICK_HELP -comment_char=$(git config --get core.commentchar 2>/dev/null | cut -c1) -: ${comment_char:=#} +comment_char=$(git config --get core.commentchar 2>/dev/null) +case "$comment_char" in +''|auto) + comment_char=#
My first thought was "this kinda defeats the purpose of auto, doesn't it". But 'auto' here is irrelevant because we control the leading character of all lines in the todo file. 'auto' makes little sense in this context, falling back to any comment char would do.
So, ack (after you fix the $(comment_char other people have mentioned, of course).
Signature · 1 line
Duy
Quoted 20 lines · Johannes Schindelin
The Git for Windows project recently got a bug report that detailed how
git rebase -ifails when core.commentchar=auto:https://groups.google.com/forum/#!topic/git-for-windows/eOZKjkgyX1Q
This patch series fixes rebase -i's handling of core.commentchar.
Johannes Schindelin (3):
rebase -i: identify problems with core.commentchar
stripspace: respect repository config rebase -i: handle core.commentChar=autobuiltin/stripspace.c | 4 +++- git-rebase--interactive.sh | 13 +++++++++++-- t/t0030-stripspace.sh | 7 +++++++ t/t3404-rebase-interactive.sh | 12 ++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-)
Quoted 7 lines
base-commit:
1310affe024fba407bff55dbe65cd6d670c8a32d
Published-As: https://github.com/dscho/git/releases/tag/rebase-i-commentchar-v1
Fetch-It-Via: git fetch https://github.com/dscho/git rebase-i-commentchar-v1--
2.10.1.583.g721a9e0
The series makes sense to me.
Thanks,
Jake