From: Junio C Hamano <hidden> Date: 2018-12-14 02:36:54
Sergey Organov [off-list ref] writes:
I came up with the following as a preparatory change. Looks acceptable?
-- 8< --
t3510: stop using '-m 1' to force failure mid-sequence of cherry-picks
We are going to allow 'git cherry-pick -m 1' for non-merge commits, so
this method to force failure will stop to work.
Use '-m 4' instead as it's very unlikely we will ever have such an
octopus in this test setup.
Yeah, that is a good approach. Thanks for coming up with it.
I agree that it also is a good idea to use a variable to avoid
repeating "4" (and risking the two uses of the constant drifting
apart), but I find a single letter variable 'm' a bit too bland and
not descriptive enough. Perhaps spell it out as mainline=4,
possibly with a comment why that is not a more-commonly-seen number
like "1"?
# to make sure that the session to cherry-pick a sequence
# gets interrupted, use a high-enough number that is larger
# than the number of parents of any commit
mainline=4 &&
or something.
@@ -64,10 +64,10 @@ test_expect_success 'merge setup' 'gitcheckout-bnewA'-test_expect_success'cherry-pick a non-merge with --ff and -m should fail''+test_expect_success'cherry-pick explicit first parent of a non-merge with --ff''gitreset--hardA--&&-test_must_failgitcherry-pick--ff-m1B&&-gitdiff--exit-codeA--+gitcherry-pick--ff-m1B&&+gitdiff--exit-codeC--' test_expect_success'cherry pick a merge with --ff but without -m should fail''
We are going to allow 'git cherry-pick -m 1' for non-merge commits, so
this method to force failure will stop to work.
Use '-m 4' instead as it's very unlikely we will ever have such an
octopus in this test setup.
Signed-off-by: Sergey Organov <redacted>
---
t/t3510-cherry-pick-sequence.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
@@ -61,7 +61,11 @@ test_expect_success 'cherry-pick mid-cherry-pick-sequence' ' test_expect_success'cherry-pick persists opts correctly''pristine_detachinitial&&-test_expect_code128gitcherry-pick-s-m1--strategy=recursive-Xpatience-Xoursinitial..anotherpick&&+# to make sure that the session to cherry-pick a sequence+# gets interrupted, use a high-enough number that is larger+# than the number of parents of any commit we have created+mainline=4&&+test_expect_code128gitcherry-pick-s-m$mainline--strategy=recursive-Xpatience-Xoursinitial..anotherpick&&test_path_is_dir.git/sequencer&&test_path_is_file.git/sequencer/head&&test_path_is_file.git/sequencer/todo&&
When cherry-picking multiple commits, it's impossible to have both
merge- and non-merge commits on the same command-line. Not specifying
'-m 1' results in cherry-pick refusing to handle merge commits, while
specifying '-m 1' fails on non-merge commits.
This patch allows '-m 1' for non-merge commits. As mainline is always
the only parent for a non-merge commit, it makes little sense to
disable it.
Signed-off-by: Sergey Organov <redacted>
---
sequencer.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
@@ -1766,9 +1766,13 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,returnerror(_("commit %s does not have parent %d"),oid_to_hex(&commit->object.oid),opts->mainline);parent=p->item;-}elseif(0<opts->mainline)-returnerror(_("mainline was specified but commit %s is not a merge."),-oid_to_hex(&commit->object.oid));+}elseif(1<opts->mainline)+/*+*Non-firstparentexplicitlyspecifiedasmainlinefor+*non-mergecommit+*/+returnerror(_("commit %s does not have parent %d"),+oid_to_hex(&commit->object.oid),opts->mainline);elseparent=commit->parents->item;
@@ -40,12 +40,12 @@ test_expect_success 'cherry-pick -m complains of bogus numbers' 'test_expect_code129gitcherry-pick-m0b'-test_expect_success'cherry-pick a non-merge with -m should fail''+test_expect_success'cherry-pick explicit first parent of a non-merge''gitreset--hard&&gitcheckouta^0&&-test_expect_code128gitcherry-pick-m1b&&-gitdiff--exit-codea--+gitcherry-pick-m1b&&+gitdiff--exit-codec--'
@@ -84,12 +84,12 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent should f'-test_expect_success'revert a non-merge with -m should fail''+test_expect_success'revert explicit first parent of a non-merge''gitreset--hard&&gitcheckoutc^0&&-test_must_failgitrevert-m1b&&-gitdiff--exit-codec+gitrevert-m1b&&+gitdiff--exit-codea'
When cherry-picking multiple commits, it's impossible to have both
merge- and non-merge commits on the same command-line. Not specifying
'-m 1' results in cherry-pick refusing to handle merge commits, while
specifying '-m 1' fails on non-merge commits.
This patch series allow '-m 1' for non-merge commits as well as fixes
relevant tests in accordance.
It also opens the way to making '-m 1' the default, that would be
inline with the trends to assume first parent to be the mainline in
most workflows.
Sergey Organov (4):
t3510: stop using '-m 1' to force failure mid-sequence of cherry-picks
cherry-pick: do not error on non-merge commits when '-m 1' is
specified
t3502: validate '-m 1' argument is now accepted for non-merge commits
t3506: validate '-m 1 -ff' is now accepted for non-merge commits
sequencer.c | 10 +++++++---
t/t3502-cherry-pick-merge.sh | 12 ++++++------
t/t3506-cherry-pick-ff.sh | 6 +++---
t/t3510-cherry-pick-sequence.sh | 8 ++++++--
4 files changed, 22 insertions(+), 14 deletions(-)
--
2.10.0.1.g57b01a3
@@ -40,12 +40,12 @@ test_expect_success 'cherry-pick -m complains of bogus numbers' 'test_expect_code129gitcherry-pick-m0b'-test_expect_success'cherry-pick a non-merge with -m should fail''+test_expect_success'cherry-pick explicit first parent of a non-merge''gitreset--hard&&gitcheckouta^0&&-test_expect_code128gitcherry-pick-m1b&&-gitdiff--exit-codea--+gitcherry-pick-m1b&&+gitdiff--exit-codec--'
@@ -84,12 +84,12 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent should f'-test_expect_success'revert a non-merge with -m should fail''+test_expect_success'revert explicit first parent of a non-merge''gitreset--hard&&gitcheckoutc^0&&-test_must_failgitrevert-m1b&&-gitdiff--exit-codec+gitrevert-m1b&&+gitdiff--exit-codea
You need disambiguaion here, otherwise this test fails on
case-insensitive file systems:
++git diff --exit-code a
fatal: ambiguous argument 'a': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
error: last command exited with $?=128
not ok 8 - revert explicit first parent of a non-merge
Change from v2: t/t3502: disambiguation added to prevent failing on
case-insensitive file systems.
When cherry-picking multiple commits, it's impossible to have both
merge- and non-merge commits on the same command-line. Not specifying
'-m 1' results in cherry-pick refusing to handle merge commits, while
specifying '-m 1' fails on non-merge commits.
This patch series allow '-m 1' for non-merge commits as well as fixes
relevant tests in accordance.
It also opens the way to making '-m 1' the default, that would be
inline with the trends to assume first parent to be the mainline in
most workflows.
Sergey Organov (4):
t3510: stop using '-m 1' to force failure mid-sequence of cherry-picks
cherry-pick: do not error on non-merge commits when '-m 1' is
specified
t3502: validate '-m 1' argument is now accepted for non-merge commits
t3506: validate '-m 1 -ff' is now accepted for non-merge commits
sequencer.c | 10 +++++++---
t/t3502-cherry-pick-merge.sh | 12 ++++++------
t/t3506-cherry-pick-ff.sh | 6 +++---
t/t3510-cherry-pick-sequence.sh | 8 ++++++--
4 files changed, 22 insertions(+), 14 deletions(-)
--
2.10.0.1.g57b01a3
We are going to allow 'git cherry-pick -m 1' for non-merge commits, so
this method to force failure will stop to work.
Use '-m 4' instead as it's very unlikely we will ever have such an
octopus in this test setup.
Signed-off-by: Sergey Organov <redacted>
---
t/t3510-cherry-pick-sequence.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
@@ -61,7 +61,11 @@ test_expect_success 'cherry-pick mid-cherry-pick-sequence' ' test_expect_success'cherry-pick persists opts correctly''pristine_detachinitial&&-test_expect_code128gitcherry-pick-s-m1--strategy=recursive-Xpatience-Xoursinitial..anotherpick&&+# to make sure that the session to cherry-pick a sequence+# gets interrupted, use a high-enough number that is larger+# than the number of parents of any commit we have created+mainline=4&&+test_expect_code128gitcherry-pick-s-m$mainline--strategy=recursive-Xpatience-Xoursinitial..anotherpick&&test_path_is_dir.git/sequencer&&test_path_is_file.git/sequencer/head&&test_path_is_file.git/sequencer/todo&&
When cherry-picking multiple commits, it's impossible to have both
merge- and non-merge commits on the same command-line. Not specifying
'-m 1' results in cherry-pick refusing to handle merge commits, while
specifying '-m 1' fails on non-merge commits.
This patch allows '-m 1' for non-merge commits. As mainline is always
the only parent for a non-merge commit, it makes little sense to
disable it.
Signed-off-by: Sergey Organov <redacted>
---
sequencer.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
@@ -1766,9 +1766,13 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,returnerror(_("commit %s does not have parent %d"),oid_to_hex(&commit->object.oid),opts->mainline);parent=p->item;-}elseif(0<opts->mainline)-returnerror(_("mainline was specified but commit %s is not a merge."),-oid_to_hex(&commit->object.oid));+}elseif(1<opts->mainline)+/*+*Non-firstparentexplicitlyspecifiedasmainlinefor+*non-mergecommit+*/+returnerror(_("commit %s does not have parent %d"),+oid_to_hex(&commit->object.oid),opts->mainline);elseparent=commit->parents->item;
@@ -40,12 +40,12 @@ test_expect_success 'cherry-pick -m complains of bogus numbers' 'test_expect_code129gitcherry-pick-m0b'-test_expect_success'cherry-pick a non-merge with -m should fail''+test_expect_success'cherry-pick explicit first parent of a non-merge''gitreset--hard&&gitcheckouta^0&&-test_expect_code128gitcherry-pick-m1b&&-gitdiff--exit-codea--+gitcherry-pick-m1b&&+gitdiff--exit-codec--'
@@ -84,12 +84,12 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent should f'-test_expect_success'revert a non-merge with -m should fail''+test_expect_success'revert explicit first parent of a non-merge''gitreset--hard&&gitcheckoutc^0&&-test_must_failgitrevert-m1b&&-gitdiff--exit-codec+gitrevert-m1b&&+gitdiff--exit-codea--'
@@ -64,10 +64,10 @@ test_expect_success 'merge setup' 'gitcheckout-bnewA'-test_expect_success'cherry-pick a non-merge with --ff and -m should fail''+test_expect_success'cherry-pick explicit first parent of a non-merge with --ff''gitreset--hardA--&&-test_must_failgitcherry-pick--ff-m1B&&-gitdiff--exit-codeA--+gitcherry-pick--ff-m1B&&+gitdiff--exit-codeC--' test_expect_success'cherry pick a merge with --ff but without -m should fail''