Skip to content

Commit 52eb738

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8af14f0 commit 52eb738

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Documentation/git-rebase.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ See also INCOMPATIBLE OPTIONS below.
258258
original branch. The index and working tree are also left
259259
unchanged as a result.
260260

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+
261268
--empty={drop,keep,ask}::
262269
How to handle commits that are not empty to start and are not
263270
clean cherry-picks of any upstream commit, but which become
@@ -378,7 +385,7 @@ See also INCOMPATIBLE OPTIONS below.
378385
Ensure at least <n> lines of surrounding context match before
379386
and after each change. When fewer lines of surrounding
380387
context exist they all must match. By default no context is
381-
ever ignored.
388+
ever ignored. Implies --am.
382389
+
383390
See also INCOMPATIBLE OPTIONS below.
384391

@@ -418,6 +425,7 @@ with `--keep-base` in order to drop those commits from your branch.
418425
--whitespace=<option>::
419426
These flags are passed to the 'git apply' program
420427
(see linkgit:git-apply[1]) that applies the patch.
428+
Implies --am.
421429
+
422430
See also INCOMPATIBLE OPTIONS below.
423431

@@ -561,6 +569,7 @@ INCOMPATIBLE OPTIONS
561569

562570
The following options:
563571

572+
* --am
564573
* --committer-date-is-author-date
565574
* --ignore-date
566575
* --ignore-whitespace

builtin/rebase.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,18 @@ static int can_fast_forward(struct commit *onto, struct commit *upstream,
13351335
return res && is_linear_history(onto, head);
13361336
}
13371337

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+
13381350
/* -i followed by -m is still -i */
13391351
static int parse_opt_merge(const struct option *opt, const char *arg, int unset)
13401352
{
@@ -1519,6 +1531,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15191531
OPT_CMDMODE(0, "show-current-patch", &action,
15201532
N_("show the patch file being applied or merged"),
15211533
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 },
15221538
{ OPTION_CALLBACK, 'm', "merge", &options, NULL,
15231539
N_("use merging strategies to rebase"),
15241540
PARSE_OPT_NOARG | PARSE_OPT_NONEG,
@@ -1878,7 +1894,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
18781894
if (isatty(2) && options.flags & REBASE_NO_QUIET)
18791895
strbuf_addstr(&options.git_format_patch_opt, " --progress");
18801896

1881-
if (options.git_am_opts.argc) {
1897+
if (options.git_am_opts.argc || options.type == REBASE_AM) {
18821898
/* all am options except -q are compatible only with --am */
18831899
for (i = options.git_am_opts.argc - 1; i >= 0; i--)
18841900
if (strcmp(options.git_am_opts.argv[i], "-q"))

0 commit comments

Comments
 (0)