rebase: add an --am option
Currently, this option doesn't do anything except error out if any options requiring the interactive-backend are also passed. However, when we make the default backend configurable later in this series, this flag will provide a way to override the config setting. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Feb 15, 2020 at 21:36 UTC
52eb738d6b40bf8816727fcf7f39febc761ef0db
2 files changed
+27
-2
Documentation/git-rebase.txt
+10
-1
@@ -258,6 +258,13 @@ See also INCOMPATIBLE OPTIONS below.
258
original branch. The index and working tree are also left
259
unchanged as a result.
260
261
+--am:
262
+ Use git-am internally to rebase. This option may become a
263
+ no-op in the future once the interactive backend handles
264
+ everything the am one does.
265
++
266
+See also INCOMPATIBLE OPTIONS below.
267
+
268
--empty={drop,keep,ask}::
269
How to handle commits that are not empty to start and are not
270
clean cherry-picks of any upstream commit, but which become
@@ -378,7 +385,7 @@ See also INCOMPATIBLE OPTIONS below.
385
Ensure at least <n> lines of surrounding context match before
386
and after each change. When fewer lines of surrounding
387
context exist they all must match. By default no context is
381
- ever ignored.
388
+ ever ignored. Implies --am.
389
+
390
See also INCOMPATIBLE OPTIONS below.
391
@@ -418,6 +425,7 @@ with `--keep-base` in order to drop those commits from your branch.
425
--whitespace=<option>::
426
These flags are passed to the 'git apply' program
427
(see linkgit:git-apply[1]) that applies the patch.
428
+ Implies --am.
429
+
430
See also INCOMPATIBLE OPTIONS below.
431
@@ -561,6 +569,7 @@ INCOMPATIBLE OPTIONS
569
570
The following options:
571
572
+ * --am
573
* --committer-date-is-author-date
574
* --ignore-date
575
* --ignore-whitespace
builtin/rebase.c
+17
-1
@@ -1335,6 +1335,18 @@ done:
1335
return res && is_linear_history(onto, head);
1336
}
1337
1338
+static int parse_opt_am(const struct option *opt, const char *arg, int unset)
1339
+{
1340
+ struct rebase_options *opts = opt->value;
1341
+
1342
+ BUG_ON_OPT_NEG(unset);
1343
+ BUG_ON_OPT_ARG(arg);
1344
+
1345
+ opts->type = REBASE_AM;
1346
+
1347
+ return 0;
1348
+}
1349
+
1350
/* -i followed by -m is still -i */
1351
static int parse_opt_merge(const struct option *opt, const char *arg, int unset)
1352
{
@@ -1519,6 +1531,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1531
OPT_CMDMODE(0, "show-current-patch", &action,
1532
N_("show the patch file being applied or merged"),
1533
ACTION_SHOW_CURRENT_PATCH),
1534
+ { OPTION_CALLBACK, 0, "am", &options, NULL,
1535
+ N_("use apply-mail strategies to rebase"),
1536
+ PARSE_OPT_NOARG | PARSE_OPT_NONEG,
1537
+ parse_opt_am },
1538
{ OPTION_CALLBACK, 'm', "merge", &options, NULL,
1539
N_("use merging strategies to rebase"),
1540
PARSE_OPT_NOARG | PARSE_OPT_NONEG,
@@ -1878,7 +1894,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1894
if (isatty(2) && options.flags & REBASE_NO_QUIET)
1895
strbuf_addstr(&options.git_format_patch_opt, " --progress");
1896
1881
- if (options.git_am_opts.argc) {
1897
+ if (options.git_am_opts.argc || options.type == REBASE_AM) {
1898
/* all am options except -q are compatible only with --am */
1899
for (i = options.git_am_opts.argc - 1; i >= 0; i--)
1900
if (strcmp(options.git_am_opts.argv[i], "-q"))