summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-02-23 13:39:54 +0100
committerJunio C Hamano <gitster@pobox.com>2018-02-23 11:30:52 -0800
commit5e05825de07c16b810f1b996b7eab3527a95a097 (patch)
treec3d32126843908408b1357aa77d2c87bc66b1c35 /t
parent67f6905b8ac3468f271866e819232440238f9525 (diff)
downloadgit-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 't')
-rwxr-xr-xt/t3430-rebase-recreate-merges.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/t/t3430-rebase-recreate-merges.sh b/t/t3430-rebase-recreate-merges.sh
index 2fb74cbbd3..f2f44d2a66 100755
--- a/t/t3430-rebase-recreate-merges.sh
+++ b/t/t3430-rebase-recreate-merges.sh
@@ -143,6 +143,29 @@ test_expect_success 'with a branch tip that was cherry-picked already' '
EOF
'
+test_expect_success 'do not rebase cousins unless asked for' '
+ write_script copy-editor.sh <<-\EOF &&
+ cp "$1" "$(git rev-parse --git-path ORIGINAL-TODO)"
+ EOF
+
+ test_config sequence.editor \""$PWD"/copy-editor.sh\" &&
+ git checkout -b cousins master &&
+ before="$(git rev-parse --verify HEAD)" &&
+ test_tick &&
+ git rebase -i --recreate-merges HEAD^ &&
+ test_cmp_rev HEAD $before &&
+ test_tick &&
+ git rebase -i --recreate-merges=rebase-cousins HEAD^ &&
+ test_cmp_graph HEAD^.. <<-\EOF
+ * Merge the topic branch '\''onebranch'\''
+ |\
+ | * D
+ | * G
+ |/
+ o H
+ EOF
+'
+
test_expect_success 'refs/rewritten/* is worktree-local' '
git worktree add wt &&
cat >wt/script-from-scratch <<-\EOF &&