Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-15 19:56:23 +0300
committerJunio C Hamano <gitster@pobox.com>2017-03-15 22:08:36 +0300
commitb16a991c1be5681b4b673d4343dfcc0c2f5ad498 (patch)
tree7b5f6a56e3955b4f1b0fbfbf5413007289892bc7 /t/t3502-cherry-pick-merge.sh
parentc3808ca6982b0ad7ee9b87eca9b50b9a24ec08b0 (diff)
cherry-pick: detect bogus arguments to --mainline
The cherry-pick and revert commands use OPT_INTEGER() to parse --mainline. The stock parser is smart enough to reject non-numeric nonsense, but it doesn't know that parent counting starts at 1. Worse, the value "0" is indistinguishable from the unset case, so a user who assumes the counting is 0-based will get a confusing message: $ git cherry-pick -m 0 $merge error: commit ... is a merge but no -m option was given. Let's use a custom callback that enforces our range. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3502-cherry-pick-merge.sh')
-rwxr-xr-xt/t3502-cherry-pick-merge.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/t/t3502-cherry-pick-merge.sh b/t/t3502-cherry-pick-merge.sh
index e37547f41a..b1602718f8 100755
--- a/t/t3502-cherry-pick-merge.sh
+++ b/t/t3502-cherry-pick-merge.sh
@@ -31,6 +31,15 @@ test_expect_success setup '
'
+test_expect_success 'cherry-pick -m complains of bogus numbers' '
+ # expect 129 here to distinguish between cases where
+ # there was nothing to cherry-pick
+ test_expect_code 129 git cherry-pick -m &&
+ test_expect_code 129 git cherry-pick -m foo b &&
+ test_expect_code 129 git cherry-pick -m -1 b &&
+ test_expect_code 129 git cherry-pick -m 0 b
+'
+
test_expect_success 'cherry-pick a non-merge with -m should fail' '
git reset --hard &&