]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/rebase-deprecate-preserve-merges'
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Apr 2019 17:14:24 +0000 (02:14 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Apr 2019 17:14:24 +0000 (02:14 +0900)
"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

1  2 
Documentation/git-rebase.txt
builtin/rebase.c

index 6363d674b775fd49b63fcdd3ceb42440a35dd959,63047375b61baaff2fd1767f711a7d903f719e01..44e00329e1b0e6b1c3d55316121992492f5b1ea9
@@@ -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 `<upstream>` 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 `<upstream>` (or `<onto>`, 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 77deebc65c6bd7fbe6261b91cfb78c7ec3f85c2d,21ac10f739997e32297cd0c080c4ede41b195300..551b72f52d67718c61305794e6bffbb32cd728ee
@@@ -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,
        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");
                                 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 "
                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);
        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);
                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;