44
45
enum rebase_type {
46
REBASE_UNSPECIFIED = -1,
47
- REBASE_AM,
47
+ REBASE_APPLY,
48
REBASE_MERGE,
49
- REBASE_INTERACTIVE,
49
REBASE_PRESERVE_MERGES
50
};
51
379
return ret;
380
}
381
383
-static int run_rebase_interactive(struct rebase_options *opts,
382
+static int run_sequencer_rebase(struct rebase_options *opts,
383
enum action command)
384
{
385
unsigned flags = 0;
461
* If we ever want to remap --keep-empty to --empty=keep, insert:
462
* opts->empty = unset ? EMPTY_UNSPECIFIED : EMPTY_KEEP;
463
*/
465
- opts->type = REBASE_INTERACTIVE;
464
+ opts->type = REBASE_MERGE;
465
return 0;
466
}
467
554
warning(_("--[no-]rebase-cousins has no effect without "
555
"--rebase-merges"));
556
558
- return !!run_rebase_interactive(&opts, command);
557
+ return !!run_sequencer_rebase(&opts, command);
558
}
559
561
-static int is_interactive(struct rebase_options *opts)
560
+static int is_merge(struct rebase_options *opts)
561
{
563
- return opts->type == REBASE_INTERACTIVE ||
562
+ return opts->type == REBASE_MERGE ||
563
opts->type == REBASE_PRESERVE_MERGES;
564
}
565
567
-static void imply_interactive(struct rebase_options *opts, const char *option)
566
+static void imply_merge(struct rebase_options *opts, const char *option)
567
{
568
switch (opts->type) {
570
- case REBASE_AM:
569
+ case REBASE_APPLY:
570
die(_("%s requires an interactive rebase"), option);
571
break;
573
- case REBASE_INTERACTIVE:
572
+ case REBASE_MERGE:
573
case REBASE_PRESERVE_MERGES:
574
break;
576
- case REBASE_MERGE:
577
- /* we now implement --merge via --interactive */
575
default:
579
- opts->type = REBASE_INTERACTIVE; /* implied */
576
+ opts->type = REBASE_MERGE; /* implied */
577
break;
578
}
579
}
782
* user should see them.
783
*/
784
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
788
- if (opts->type == REBASE_INTERACTIVE) {
785
+ if (opts->type == REBASE_MERGE) {
786
struct replay_opts replay = REPLAY_OPTS_INIT;
787
788
replay.action = REPLAY_INTERACTIVE_REBASE;
1115
int status;
1116
const char *backend, *backend_func;
1117
1121
- if (opts->type == REBASE_INTERACTIVE) {
1122
- /* Run builtin interactive rebase */
1118
+ if (opts->type == REBASE_MERGE) {
1119
+ /* Run sequencer-based rebase */
1120
setenv("GIT_CHERRY_PICK_HELP", resolvemsg, 1);
1121
if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
1122
setenv("GIT_SEQUENCE_EDITOR", ":", 1);
1129
opts->gpg_sign_opt = tmp;
1130
}
1131
1135
- status = run_rebase_interactive(opts, action);
1132
+ status = run_sequencer_rebase(opts, action);
1133
goto finished_rebase;
1134
}
1135
1139
- if (opts->type == REBASE_AM) {
1136
+ if (opts->type == REBASE_APPLY) {
1137
status = run_am(opts);
1138
goto finished_rebase;
1139
}
1187
add_var(&script_snippet, "git_format_patch_opt",
1188
opts->git_format_patch_opt.buf);
1189
1193
- if (is_interactive(opts) &&
1190
+ if (is_merge(opts) &&
1191
!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
1192
strbuf_addstr(&script_snippet,
1193
"GIT_SEQUENCE_EDITOR=:; export GIT_SEQUENCE_EDITOR; ");
1212
finished_rebase:
1213
if (opts->dont_finish_rebase)
1214
; /* do nothing */
1218
- else if (opts->type == REBASE_INTERACTIVE)
1219
- ; /* interactive rebase cleans up after itself */
1215
+ else if (opts->type == REBASE_MERGE)
1216
+ ; /* merge backend cleans up after itself */
1217
else if (status == 0) {
1218
if (!file_exists(state_dir_path("stopped-sha", opts)))
1219
finish_rebase(opts);
1345
BUG_ON_OPT_NEG(unset);
1346
BUG_ON_OPT_ARG(arg);
1347
1351
- opts->type = REBASE_AM;
1348
+ opts->type = REBASE_APPLY;
1349
1350
return 0;
1351
}
1358
BUG_ON_OPT_NEG(unset);
1359
BUG_ON_OPT_ARG(arg);
1360
1364
- if (!is_interactive(opts))
1361
+ if (!is_merge(opts))
1362
opts->type = REBASE_MERGE;
1363
1364
return 0;
1373
BUG_ON_OPT_NEG(unset);
1374
BUG_ON_OPT_ARG(arg);
1375
1379
- opts->type = REBASE_INTERACTIVE;
1376
+ opts->type = REBASE_MERGE;
1377
opts->flags |= REBASE_INTERACTIVE_EXPLICIT;
1378
1379
return 0;
1437
const char *env;
1438
struct strbuf buf = STRBUF_INIT;
1439
1443
- if (!is_interactive(options))
1440
+ if (!is_merge(options))
1441
return;
1442
1443
env = getenv(GIT_REFLOG_ACTION_ENVIRONMENT);
1534
OPT_CMDMODE(0, "show-current-patch", &action,
1535
N_("show the patch file being applied or merged"),
1536
ACTION_SHOW_CURRENT_PATCH),
1540
- { OPTION_CALLBACK, 0, "am", &options, NULL,
1541
- N_("use apply-mail strategies to rebase"),
1537
+ { OPTION_CALLBACK, 0, "apply", &options, NULL,
1538
+ N_("use apply strategies to rebase"),
1539
PARSE_OPT_NOARG | PARSE_OPT_NONEG,
1540
parse_opt_am },
1541
{ OPTION_CALLBACK, 'm', "merge", &options, NULL,
1612
die(_("It looks like 'git am' is in progress. Cannot rebase."));
1613
1614
if (is_directory(apply_dir())) {
1618
- options.type = REBASE_AM;
1615
+ options.type = REBASE_APPLY;
1616
options.state_dir = apply_dir();
1617
} else if (is_directory(merge_dir())) {
1618
strbuf_reset(&buf);
1624
strbuf_reset(&buf);
1625
strbuf_addf(&buf, "%s/interactive", merge_dir());
1626
if(file_exists(buf.buf)) {
1630
- options.type = REBASE_INTERACTIVE;
1627
+ options.type = REBASE_MERGE;
1628
options.flags |= REBASE_INTERACTIVE_EXPLICIT;
1629
} else
1630
options.type = REBASE_MERGE;
1664
die(_("No rebase in progress?"));
1665
setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0);
1666
1670
- if (action == ACTION_EDIT_TODO && !is_interactive(&options))
1667
+ if (action == ACTION_EDIT_TODO && !is_merge(&options))
1668
die(_("The --edit-todo action can only be used during "
1669
"interactive rebase."));
1670
1671
if (trace2_is_enabled()) {
1675
- if (is_interactive(&options))
1672
+ if (is_merge(&options))
1673
trace2_cmd_mode("interactive");
1674
else if (exec.nr)
1675
trace2_cmd_mode("interactive-exec");
1745
goto cleanup;
1746
}
1747
case ACTION_QUIT: {
1751
- if (options.type == REBASE_INTERACTIVE) {
1748
+ if (options.type == REBASE_MERGE) {
1749
struct replay_opts replay = REPLAY_OPTS_INIT;
1750
1751
replay.action = REPLAY_INTERACTIVE_REBASE;
1828
argv_array_push(&options.git_am_opts, "-q");
1829
1830
if (options.empty != EMPTY_UNSPECIFIED)
1834
- imply_interactive(&options, "--empty");
1831
+ imply_merge(&options, "--empty");
1832
1833
if (gpg_sign) {
1834
free(options.gpg_sign_opt);
1838
if (exec.nr) {
1839
int i;
1840
1844
- imply_interactive(&options, "--exec");
1841
+ imply_merge(&options, "--exec");
1842
1843
strbuf_reset(&buf);
1844
for (i = 0; i < exec.nr; i++)
1854
else if (strcmp("no-rebase-cousins", rebase_merges))
1855
die(_("Unknown mode: %s"), rebase_merges);
1856
options.rebase_merges = 1;
1860
- imply_interactive(&options, "--rebase-merges");
1857
+ imply_merge(&options, "--rebase-merges");
1858
}
1859
1860
if (strategy_options.nr) {
1873
if (options.strategy) {
1874
options.strategy = xstrdup(options.strategy);
1875
switch (options.type) {
1879
- case REBASE_AM:
1876
+ case REBASE_APPLY:
1877
die(_("--strategy requires --merge or --interactive"));
1878
case REBASE_MERGE:
1882
- case REBASE_INTERACTIVE:
1879
case REBASE_PRESERVE_MERGES:
1880
/* compatible */
1881
break;
1888
}
1889
1890
if (options.type == REBASE_MERGE)
1895
- imply_interactive(&options, "--merge");
1891
+ imply_merge(&options, "--merge");
1892
1893
if (options.root && !options.onto_name)
1898
- imply_interactive(&options, "--root without --onto");
1894
+ imply_merge(&options, "--root without --onto");
1895
1896
if (isatty(2) && options.flags & REBASE_NO_QUIET)
1897
strbuf_addstr(&options.git_format_patch_opt, " --progress");
1898
1903
- if (options.git_am_opts.argc || options.type == REBASE_AM) {
1904
- /* all am options except -q are compatible only with --am */
1899
+ if (options.git_am_opts.argc || options.type == REBASE_APPLY) {
1900
+ /* all am options except -q are compatible only with --apply */
1901
for (i = options.git_am_opts.argc - 1; i >= 0; i--)
1902
if (strcmp(options.git_am_opts.argv[i], "-q"))
1903
break;
1904
1905
if (i >= 0) {
1910
- if (is_interactive(&options))
1911
- die(_("cannot combine am options with either "
1912
- "interactive or merge options"));
1906
+ if (is_merge(&options))
1907
+ die(_("cannot combine apply options with "
1908
+ "merge options"));
1909
else
1914
- options.type = REBASE_AM;
1910
+ options.type = REBASE_APPLY;
1911
}
1912
}
1913
1914
if (options.type == REBASE_UNSPECIFIED) {
1915
if (!strcmp(options.default_backend, "merge"))
1920
- imply_interactive(&options, "--merge");
1921
- else if (!strcmp(options.default_backend, "am"))
1922
- options.type = REBASE_AM;
1916
+ imply_merge(&options, "--merge");
1917
+ else if (!strcmp(options.default_backend, "apply"))
1918
+ options.type = REBASE_APPLY;
1919
else
1920
die(_("Unknown rebase backend: %s"),
1921
options.default_backend);
1923
1924
switch (options.type) {
1925
case REBASE_MERGE:
1930
- case REBASE_INTERACTIVE:
1926
case REBASE_PRESERVE_MERGES:
1927
options.state_dir = merge_dir();
1928
break;
1934
- case REBASE_AM:
1929
+ case REBASE_APPLY:
1930
options.state_dir = apply_dir();
1931
break;
1932
default:
1941
else
1942
options.empty = EMPTY_DROP;
1943
}
1949
- if (reschedule_failed_exec > 0 && !is_interactive(&options))
1944
+ if (reschedule_failed_exec > 0 && !is_merge(&options))
1945
die(_("--reschedule-failed-exec requires "
1946
"--exec or --interactive"));
1947
if (reschedule_failed_exec >= 0)
2242
diff_flush(&opts);
2243
}
2244
2250
- if (is_interactive(&options))
2245
+ if (is_merge(&options))
2246
goto run_rebase;
2247
2248
/* Detach HEAD and reset the tree */