From: Junio C Hamano Date: Tue, 9 Apr 2019 17:14:24 +0000 (+0900) Subject: Merge branch 'js/rebase-deprecate-preserve-merges' X-Git-Tag: v2.22.0-rc0~125 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/fa1b86e45743fd5895c33adcd3769782e608bb40?ds=inline;hp=-c Merge branch 'js/rebase-deprecate-preserve-merges' "git rebase --rebase-merges" replaces its old "--preserve-merges" option; the latter is now marked as deprecated. * js/rebase-deprecate-preserve-merges: rebase: deprecate --preserve-merges --- fa1b86e45743fd5895c33adcd3769782e608bb40 diff --combined Documentation/git-rebase.txt index 6363d674b7,63047375b6..44e00329e1 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@@ -410,14 -410,14 +410,14 @@@ See also INCOMPATIBLE OPTIONS below + By default, or when `no-rebase-cousins` was specified, commits which do not have `` as direct ancestor will keep their original branch point, -i.e. commits that would be excluded by gitlink:git-log[1]'s +i.e. commits that would be excluded by linkgit:git-log[1]'s `--ancestry-path` option will keep their original ancestry by default. If the `rebase-cousins` mode is turned on, such commits are instead rebased onto `` (or ``, if specified). + - The `--rebase-merges` mode is similar in spirit to `--preserve-merges`, but - in contrast to that option works well in interactive rebases: commits can be - reordered, inserted and dropped at will. + The `--rebase-merges` mode is similar in spirit to the deprecated + `--preserve-merges`, but in contrast to that option works well in interactive + rebases: commits can be reordered, inserted and dropped at will. + It is currently only possible to recreate the merge commits using the `recursive` merge strategy; Different merge strategies can be used only via @@@ -427,9 -427,10 +427,10 @@@ See also REBASING MERGES and INCOMPATIB -p:: --preserve-merges:: - Recreate merge commits instead of flattening the history by replaying - commits a merge commit introduces. Merge conflict resolutions or manual - amendments to merge commits are not preserved. + [DEPRECATED: use `--rebase-merges` instead] Recreate merge commits + instead of flattening the history by replaying commits a merge commit + introduces. Merge conflict resolutions or manual amendments to merge + commits are not preserved. + This uses the `--interactive` machinery internally, but combining it with the `--interactive` option explicitly is generally not a good @@@ -1020,11 -1021,11 +1021,11 @@@ merge cmak BUGS ---- - The todo list presented by `--preserve-merges --interactive` does not - represent the topology of the revision graph. Editing commits and - rewording their commit messages should work fine, but attempts to - reorder commits tend to produce counterintuitive results. Use - `--rebase-merges` in such scenarios instead. + The todo list presented by the deprecated `--preserve-merges --interactive` + does not represent the topology of the revision graph (use `--rebase-merges` + instead). Editing commits and rewording their commit messages should work + fine, but attempts to reorder commits tend to produce counterintuitive results. + Use `--rebase-merges` in such scenarios instead. For example, an attempt to rearrange ------------ diff --combined builtin/rebase.c index 77deebc65c,21ac10f739..551b72f52d --- a/builtin/rebase.c +++ b/builtin/rebase.c @@@ -369,7 -369,6 +369,7 @@@ static void add_var(struct strbuf *buf #define RESET_HEAD_HARD (1<<1) #define RESET_HEAD_RUN_POST_CHECKOUT_HOOK (1<<2) #define RESET_HEAD_REFS_ONLY (1<<3) +#define RESET_ORIG_HEAD (1<<4) static int reset_head(struct object_id *oid, const char *action, const char *switch_to_branch, unsigned flags, @@@ -379,7 -378,6 +379,7 @@@ unsigned reset_hard = flags & RESET_HEAD_HARD; unsigned run_hook = flags & RESET_HEAD_RUN_POST_CHECKOUT_HOOK; unsigned refs_only = flags & RESET_HEAD_REFS_ONLY; + unsigned update_orig_head = flags & RESET_ORIG_HEAD; struct object_id head_oid; struct tree_desc desc[2] = { { NULL }, { NULL } }; struct lock_file lock = LOCK_INIT; @@@ -456,21 -454,18 +456,21 @@@ reset_head_refs strbuf_addf(&msg, "%s: ", reflog_action ? reflog_action : "rebase"); prefix_len = msg.len; - if (!get_oid("ORIG_HEAD", &oid_old_orig)) - old_orig = &oid_old_orig; - if (!get_oid("HEAD", &oid_orig)) { - orig = &oid_orig; - if (!reflog_orig_head) { - strbuf_addstr(&msg, "updating ORIG_HEAD"); - reflog_orig_head = msg.buf; - } - update_ref(reflog_orig_head, "ORIG_HEAD", orig, old_orig, 0, - UPDATE_REFS_MSG_ON_ERR); - } else if (old_orig) - delete_ref(NULL, "ORIG_HEAD", old_orig, 0); + if (update_orig_head) { + if (!get_oid("ORIG_HEAD", &oid_old_orig)) + old_orig = &oid_old_orig; + if (!get_oid("HEAD", &oid_orig)) { + orig = &oid_orig; + if (!reflog_orig_head) { + strbuf_addstr(&msg, "updating ORIG_HEAD"); + reflog_orig_head = msg.buf; + } + update_ref(reflog_orig_head, "ORIG_HEAD", orig, + old_orig, 0, UPDATE_REFS_MSG_ON_ERR); + } else if (old_orig) + delete_ref(NULL, "ORIG_HEAD", old_orig, 0); + } + if (!reflog_head) { strbuf_setlen(&msg, prefix_len); strbuf_addstr(&msg, "updating HEAD"); @@@ -481,7 -476,7 +481,7 @@@ detach_head ? REF_NO_DEREF : 0, UPDATE_REFS_MSG_ON_ERR); else { - ret = update_ref(reflog_orig_head, switch_to_branch, oid, + ret = update_ref(reflog_head, switch_to_branch, oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR); if (!ret) ret = create_symref("HEAD", switch_to_branch, @@@ -1105,8 -1100,8 +1105,8 @@@ int cmd_rebase(int argc, const char **a PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_interactive }, OPT_SET_INT('p', "preserve-merges", &options.type, - N_("try to recreate merges instead of ignoring " - "them"), REBASE_PRESERVE_MERGES), + N_("(DEPRECATED) try to recreate merges instead of " + "ignoring them"), REBASE_PRESERVE_MERGES), OPT_BOOL(0, "rerere-autoupdate", &options.allow_rerere_autoupdate, N_("allow rerere to update index with resolved " @@@ -1217,6 -1212,10 +1217,10 @@@ usage_with_options(builtin_rebase_usage, builtin_rebase_options); + if (options.type == REBASE_PRESERVE_MERGES) + warning(_("git rebase --preserve-merges is deprecated. " + "Use --rebase-merges instead.")); + if (action != NO_ACTION && !in_progress) die(_("No rebase in progress?")); setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0); @@@ -1782,8 -1781,7 +1786,8 @@@ strbuf_addf(&msg, "%s: checkout %s", getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name); if (reset_head(&options.onto->object.oid, "checkout", NULL, - RESET_HEAD_DETACH | RESET_HEAD_RUN_POST_CHECKOUT_HOOK, + RESET_HEAD_DETACH | RESET_ORIG_HEAD | + RESET_HEAD_RUN_POST_CHECKOUT_HOOK, NULL, msg.buf)) die(_("Could not detach HEAD")); strbuf_release(&msg); @@@ -1799,8 -1797,8 +1803,8 @@@ strbuf_addf(&msg, "rebase finished: %s onto %s", options.head_name ? options.head_name : "detached HEAD", oid_to_hex(&options.onto->object.oid)); - reset_head(NULL, "Fast-forwarded", options.head_name, 0, - "HEAD", msg.buf); + reset_head(NULL, "Fast-forwarded", options.head_name, + RESET_HEAD_REFS_ONLY, "HEAD", msg.buf); strbuf_release(&msg); ret = !!finish_rebase(&options); goto cleanup;