diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2018-02-23 13:39:54 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-23 11:30:52 -0800 |
commit | 5e05825de07c16b810f1b996b7eab3527a95a097 (patch) | |
tree | c3d32126843908408b1357aa77d2c87bc66b1c35 /git-rebase.sh | |
parent | 67f6905b8ac3468f271866e819232440238f9525 (diff) | |
download | git-js/rebase-recreate-merge.tar.gz |
rebase -i: introduce --recreate-merges=[no-]rebase-cousinsjs/rebase-recreate-merge
This one is a bit tricky to explain, so let's try with a diagram:
C
/ \
A - B - E - F
\ /
D
To illustrate what this new mode is all about, let's consider what
happens upon `git rebase -i --recreate-merges B`, in particular to
the commit `D`. So far, the new branch structure would be:
--- C' --
/ \
A - B ------ E' - F'
\ /
D'
This is not really preserving the branch topology from before! The
reason is that the commit `D` does not have `B` as ancestor, and
therefore it gets rebased onto `B`.
This is unintuitive behavior. Even worse, when recreating branch
structure, most use cases would appear to want cousins *not* to be
rebased onto the new base commit. For example, Git for Windows (the
heaviest user of the Git garden shears, which served as the blueprint
for --recreate-merges) frequently merges branches from `next` early, and
these branches certainly do *not* want to be rebased. In the example
above, the desired outcome would look like this:
--- C' --
/ \
A - B ------ E' - F'
\ /
-- D' --
Let's introduce the term "cousins" for such commits ("D" in the
example), and let's not rebase them by default, introducing the new
"rebase-cousins" mode for use cases where they should be rebased.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-x | git-rebase.sh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/git-rebase.sh b/git-rebase.sh index d69bc7d0e0..58d778a2da 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -17,7 +17,7 @@ q,quiet! be quiet. implies --no-stat autostash automatically stash/stash pop before and after fork-point use 'merge-base --fork-point' to refine upstream onto=! rebase onto given branch instead of upstream -recreate-merges! try to recreate merges instead of skipping them +recreate-merges? try to recreate merges instead of skipping them p,preserve-merges! try to recreate merges instead of ignoring them s,strategy=! use the given merge strategy no-ff! cherry-pick all commits, even if unchanged @@ -88,6 +88,7 @@ state_dir= # One of {'', continue, skip, abort}, as parsed from command line action= recreate_merges= +rebase_cousins= preserve_merges= autosquash= keep_empty= @@ -268,6 +269,15 @@ do recreate_merges=t test -z "$interactive_rebase" && interactive_rebase=implied ;; + --recreate-merges=*) + recreate_merges=t + case "${1#*=}" in + rebase-cousins) rebase_cousins=t;; + no-rebase-cousins) rebase_cousins=;; + *) die "Unknown mode: $1";; + esac + test -z "$interactive_rebase" && interactive_rebase=implied + ;; --preserve-merges) preserve_merges=t test -z "$interactive_rebase" && interactive_rebase=implied |