From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>,
Junio C Hamano <gitster@pobox.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH v2 2/2] rebase: validate -C<n> and --whitespace=<mode> parameters early
Date: Wed, 14 Nov 2018 08:25:31 -0800 (PST) [thread overview]
Message-ID: <4c2ba5276636097a1c3bb2207c7537831e9079bc.1542212726.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.76.v2.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
It is a good idea to error out early upon seeing, say, `-Cbad`, rather
than starting the rebase only to have the `--am` backend complain later.
Let's do this.
The only options accepting parameters which we pass through to `git am`
(which may, or may not, forward them to `git apply`) are `-C` and
`--whitespace`. The other options we pass through do not accept
parameters, so we do not have to validate them here.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
builtin/rebase.c | 12 +++++++++++-
t/t3406-rebase-message.sh | 7 +++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 96ffa80b71..571cf899d5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1064,12 +1064,22 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
}
for (i = 0; i < options.git_am_opts.argc; i++) {
- const char *option = options.git_am_opts.argv[i];
+ const char *option = options.git_am_opts.argv[i], *p;
if (!strcmp(option, "--committer-date-is-author-date") ||
!strcmp(option, "--ignore-date") ||
!strcmp(option, "--whitespace=fix") ||
!strcmp(option, "--whitespace=strip"))
options.flags |= REBASE_FORCE;
+ else if (skip_prefix(option, "-C", &p)) {
+ while (*p)
+ if (!isdigit(*(p++)))
+ die(_("switch `C' expects a "
+ "numerical value"));
+ } else if (skip_prefix(option, "--whitespace=", &p)) {
+ if (*p && strcmp(p, "warn") && strcmp(p, "nowarn") &&
+ strcmp(p, "error") && strcmp(p, "error-all"))
+ die("Invalid whitespace option: '%s'", p);
+ }
}
if (!(options.flags & REBASE_NO_QUIET))
diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh
index 0392e36d23..2c79eed4fe 100755
--- a/t/t3406-rebase-message.sh
+++ b/t/t3406-rebase-message.sh
@@ -84,4 +84,11 @@ test_expect_success 'rebase --onto outputs the invalid ref' '
test_i18ngrep "invalid-ref" err
'
+test_expect_success 'error out early upon -C<n> or --whitespace=<bad>' '
+ test_must_fail git rebase -Cnot-a-number HEAD 2>err &&
+ test_i18ngrep "numerical value" err &&
+ test_must_fail git rebase --whitespace=bad HEAD 2>err &&
+ test_i18ngrep "Invalid whitespace option" err
+'
+
test_done
--
gitgitgadget
next prev parent reply other threads:[~2018-11-14 16:25 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 12:38 [PATCH 0/1] rebase: understand -C again, refactor Johannes Schindelin via GitGitGadget
2018-11-13 12:38 ` [PATCH 1/1] rebase: really just passthru the `git am` options Johannes Schindelin via GitGitGadget
2018-11-13 13:05 ` Junio C Hamano
2018-11-13 15:05 ` Phillip Wood
2018-11-13 19:21 ` Johannes Schindelin
2018-11-13 19:58 ` Phillip Wood
2018-11-13 21:50 ` rebase-in-C stability for 2.20 Ævar Arnfjörð Bjarmason
2018-11-14 0:07 ` Stefan Beller
2018-11-14 9:01 ` [PATCH 0/2] rebase.useBuiltin doc & test mode Ævar Arnfjörð Bjarmason
2018-11-14 14:07 ` Johannes Schindelin
2018-11-14 9:01 ` [PATCH 1/2] rebase doc: document rebase.useBuiltin Ævar Arnfjörð Bjarmason
2018-11-14 9:01 ` [PATCH 2/2] tests: add a special setup where rebase.useBuiltin is off Ævar Arnfjörð Bjarmason
2018-11-14 0:36 ` rebase-in-C stability for 2.20 Elijah Newren
2018-11-14 3:39 ` Junio C Hamano
2018-11-24 20:54 ` [ANNOUNCE] Git v2.20.0-rc1 Ævar Arnfjörð Bjarmason
2018-11-25 1:00 ` Junio C Hamano
2018-11-26 6:10 ` [PATCH] rebase: mark the C reimplementation as an experimental opt-in feature (was Re: [ANNOUNCE] Git v2.20.0-rc1) Junio C Hamano
2018-11-28 4:31 ` Jonathan Nieder
2018-11-28 9:23 ` Johannes Schindelin
2018-11-28 12:21 ` Ævar Arnfjörð Bjarmason
2018-11-29 4:58 ` Junio C Hamano
2018-11-29 14:17 ` Johannes Schindelin
2018-11-29 14:30 ` Ian Jackson
2018-11-29 15:39 ` Johannes Schindelin
2018-11-29 15:50 ` Ian Jackson
2018-11-29 16:14 ` Johannes Schindelin
2018-11-29 16:26 ` Ian Jackson
2018-11-26 22:52 ` [ANNOUNCE] Git v2.20.0-rc1 Johannes Schindelin
2018-11-26 23:47 ` Johannes Schindelin
2018-11-28 4:07 ` Junio C Hamano
2018-11-28 9:30 ` Johannes Schindelin
2018-11-14 14:22 ` [PATCH 1/1] rebase: really just passthru the `git am` options Johannes Schindelin
2018-11-14 7:29 ` [PATCH 0/1] rebase: understand -C again, refactor Jeff King
2018-11-14 14:28 ` Johannes Schindelin
2018-11-14 16:25 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget
2018-11-14 16:25 ` [PATCH v2 1/2] rebase: really just passthru the `git am` options Johannes Schindelin via GitGitGadget
2018-11-14 16:25 ` Johannes Schindelin via GitGitGadget [this message]
2018-11-14 16:37 ` [PATCH v2 2/2] rebase: validate -C<n> and --whitespace=<mode> parameters early Phillip Wood
2018-11-14 21:24 ` Johannes Schindelin
2018-11-19 12:38 ` Ævar Arnfjörð Bjarmason
2018-11-19 21:37 ` Git Test Coverage Report (v2.20.0-rc0) Ævar Arnfjörð Bjarmason
2018-11-20 10:58 ` [PATCH v2 2/2] rebase: validate -C<n> and --whitespace=<mode> parameters early Johannes Schindelin
2018-11-20 11:42 ` [PATCH] rebase: mark a test as failing with rebase.useBuiltin=false Ævar Arnfjörð Bjarmason
2018-11-20 19:55 ` Johannes Schindelin
-- strict thread matches above, loose matches on Subject: below --
2018-11-19 2:54 Git Test Coverage Report (v2.20.0-rc0) Derrick Stolee
2018-11-19 15:40 ` Derrick Stolee
2018-11-19 16:21 ` Jeff King
2018-11-19 18:44 ` Jeff King
2018-11-19 19:00 ` Ben Peart
2018-11-19 21:06 ` Derrick Stolee
2018-11-20 11:34 ` Jeff King
2018-11-20 12:17 ` Derrick Stolee
2018-11-20 12:40 ` Jeff King
2018-11-19 18:33 ` Ævar Arnfjörð Bjarmason
2018-11-19 18:51 ` [PATCH] tests: add a special setup where rebase.useBuiltin is off (Re: Git Test Coverage Report (v2.20.0-rc0)) Jonathan Nieder
2018-11-19 21:03 ` Ævar Arnfjörð Bjarmason
2018-11-19 19:10 ` Git Test Coverage Report (v2.20.0-rc0) Derrick Stolee
2018-11-19 19:39 ` Ævar Arnfjörð Bjarmason
2018-11-19 19:44 ` Derrick Stolee
2018-11-19 21:31 ` Derrick Stolee
2018-11-20 20:43 ` Johannes Schindelin
2018-11-21 15:20 [ANNOUNCE] Git v2.20.0-rc1 Junio C Hamano
2018-11-22 15:58 ` Ævar Arnfjörð Bjarmason
2018-11-22 19:27 ` Eric Sunshine
2018-11-22 21:12 ` [PATCH 0/2] format-patch: pre-2.20 range-diff regression fix Ævar Arnfjörð Bjarmason
2018-11-22 21:12 ` [PATCH 1/2] format-patch: add a more exhaustive --range-diff test Ævar Arnfjörð Bjarmason
2018-11-24 4:14 ` Junio C Hamano
2018-11-24 11:45 ` Ævar Arnfjörð Bjarmason
2018-11-22 21:12 ` [PATCH 2/2] format-patch: don't include --stat with --range-diff output Ævar Arnfjörð Bjarmason
2018-11-24 2:26 ` Junio C Hamano
2018-11-24 4:17 ` Junio C Hamano
2018-11-28 20:18 ` [PATCH 0/2] format-patch: fix root cause of recent regression Ævar Arnfjörð Bjarmason
2018-11-28 20:18 ` [PATCH 1/2] format-patch: add test for --range-diff diff output Ævar Arnfjörð Bjarmason
2018-11-28 20:18 ` [PATCH 2/2] format-patch: allow for independent diff & range-diff options Ævar Arnfjörð Bjarmason
2018-11-29 2:59 ` Junio C Hamano
2018-11-29 10:07 ` Johannes Schindelin
2018-11-29 10:30 ` Ævar Arnfjörð Bjarmason
2018-11-29 12:12 ` Johannes Schindelin
2018-11-29 14:35 ` Ævar Arnfjörð Bjarmason
2018-11-29 15:41 ` Johannes Schindelin
2018-11-29 16:03 ` Ævar Arnfjörð Bjarmason
2018-11-29 19:03 ` Johannes Schindelin
2018-11-30 2:30 ` Junio C Hamano
2018-11-30 4:27 ` [PATCH] format-patch: do not let its diff-options affect --range-diff (was Re: [PATCH 2/2] format-patch: allow for independent diff & range-diff options) Junio C Hamano
2018-11-30 8:57 ` Junio C Hamano
2018-11-30 9:24 ` Ævar Arnfjörð Bjarmason
2018-11-30 12:32 ` Johannes Schindelin
2018-11-30 9:31 ` Eric Sunshine
2018-12-03 13:27 ` Martin Ågren
2018-12-03 20:07 ` [PATCH v2] range-diff: always pass at least minimal diff options Martin Ågren
2018-12-03 21:21 ` [PATCH v3] " Eric Sunshine
2018-12-04 1:35 ` Junio C Hamano
2018-12-04 5:40 ` Martin Ågren
2018-11-30 9:58 ` [PATCH 2/2] format-patch: allow for independent diff & range-diff options Eric Sunshine
2018-11-26 7:35 ` [ANNOUNCE] Git v2.20.0-rc1 Junio C Hamano
2018-11-26 15:41 ` Elijah Newren
2018-11-27 0:40 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c2ba5276636097a1c3bb2207c7537831e9079bc.1542212726.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).