From 6180b202390a04c4c4f63453cdc75142bb2c8fae Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:39 -0700 Subject: t3400: stop referring to the scripted rebase One test case's title mentioned the then-current implementation detail that the `--am` backend was implemented in `git-rebase--am.sh`. This is no longer the case, so let's update the title to reflect the current reality. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3400-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 42f147858d..80b23fd326 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -285,7 +285,7 @@ EOF test_cmp From_.msg out ' -test_expect_success 'rebase--am.sh and --show-current-patch' ' +test_expect_success 'rebase --am and --show-current-patch' ' test_create_repo conflict-apply && ( cd conflict-apply && -- cgit v1.2.3 From 8c1e24048a0a159329743a8e76251412c0f727d9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:42 -0700 Subject: t3427: add a clarifying comment The flow of this test script is outright confusing, and to start the endeavor to address that, let's describe what this test is all about, and how it tries to do it. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index d8640522a0..3a2ae7b55d 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -11,6 +11,34 @@ commit_message() { git log --pretty=format:%s -1 "$1" } +# There are a few bugs in the rebase with regards to the subtree strategy, and +# this test script tries to document them. First, the following commit history +# is generated (the onelines are shown, time flows from left to right): +# +# master1 - master2 - master3 +# \ +# README ---------------------- Add subproject master - master4 - files_subtree/master5 +# +# Where the merge moves the files master[123].t into the subdirectory +# files_subtree/ and master4 as well as files_subtree/master5 add files to that +# directory directly. +# +# Then, in subsequent test cases, `git filter-branch` is used to distill just +# the commits that touch files_subtree/. To give it a final pre-rebase touch, +# an empty commit is added on top. The pre-rebase commit history looks like +# this: +# +# Add subproject master - master4 - files_subtree/master5 - Empty commit +# +# where the root commit adds three files: master1.t, master2.t and master3.t. +# +# This commit history is then rebased onto `master3` with the +# `-Xsubtree=files_subtree` option in three different ways: +# +# 1. using `--preserve-merges` +# 2. using `--preserve-merges` and --keep-empty +# 3. without specifying a rebase backend + test_expect_success 'setup' ' test_commit README && mkdir files && -- cgit v1.2.3 From c248d32cdb302812585823231cf29027db33571e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:42 -0700 Subject: t3427: simplify the `setup` test case significantly It still does the very same thing as before, but expresses it in a much more succinct (and still quite readable) manner. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 3a2ae7b55d..36c4f92e06 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -41,27 +41,21 @@ commit_message() { test_expect_success 'setup' ' test_commit README && - mkdir files && - ( - cd files && - git init && - test_commit master1 && - test_commit master2 && - test_commit master3 - ) && - git fetch files master && - git branch files-master FETCH_HEAD && - git read-tree --prefix=files_subtree files-master && - git checkout -- files_subtree && - tree=$(git write-tree) && - head=$(git rev-parse HEAD) && - rev=$(git rev-parse --verify files-master^0) && - commit=$(git commit-tree -p $head -p $rev -m "Add subproject master" $tree) && - git update-ref HEAD $commit && - ( - cd files_subtree && - test_commit master4 - ) && + + git init files && + test_commit -C files master1 && + test_commit -C files master2 && + test_commit -C files master3 && + + : perform subtree merge into files_subtree/ && + git fetch files refs/heads/master:refs/heads/files-master && + git merge -s ours --no-commit --allow-unrelated-histories \ + files-master && + git read-tree --prefix=files_subtree -u files-master && + git commit -m "Add subproject master" && + + : add two extra commits to rebase && + test_commit -C files_subtree master4 && test_commit files_subtree/master5 ' -- cgit v1.2.3 From d51b771dc0a2ea71c44f3c4c54230f140588bacd Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:43 -0700 Subject: t3427: move the `filter-branch` invocation into the `setup` case The step to prepare a pre-rebase commit history is _identical_ in _all_ of the test cases (except of course the `setup` case). It should therefore clearly a part of the `setup` test case instead. As the `git filter-branch` command is quite costly on platforms where Unix shell scripting is simply slow (meaning: on Windows), this shaves off a noticeable part of the runtime: in this developer's setup, the time was reduced from ~1m25s to ~1m. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 36c4f92e06..64ba95f3e0 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -56,16 +56,18 @@ test_expect_success 'setup' ' : add two extra commits to rebase && test_commit -C files_subtree master4 && - test_commit files_subtree/master5 + test_commit files_subtree/master5 && + + git checkout -b to-rebase && + git filter-branch --prune-empty -f --subdirectory-filter files_subtree && + git commit -m "Empty commit" --allow-empty ' # FAILURE: Does not preserve master4. test_expect_failure REBASE_P \ 'Rebase -Xsubtree --preserve-merges --onto commit 4' ' reset_rebase && - git checkout -b rebase-preserve-merges-4 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-preserve-merges-4 to-rebase && git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && verbose test "$(commit_message HEAD~)" = "files_subtree/master4" ' @@ -74,9 +76,7 @@ test_expect_failure REBASE_P \ test_expect_failure REBASE_P \ 'Rebase -Xsubtree --preserve-merges --onto commit 5' ' reset_rebase && - git checkout -b rebase-preserve-merges-5 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-preserve-merges-5 to-rebase && git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && verbose test "$(commit_message HEAD)" = "files_subtree/master5" ' @@ -85,9 +85,7 @@ test_expect_failure REBASE_P \ test_expect_failure REBASE_P \ 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 4' ' reset_rebase && - git checkout -b rebase-keep-empty-4 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-keep-empty-4 to-rebase && git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" ' @@ -96,9 +94,7 @@ test_expect_failure REBASE_P \ test_expect_failure REBASE_P \ 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 5' ' reset_rebase && - git checkout -b rebase-keep-empty-5 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-keep-empty-5 to-rebase && git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" ' @@ -107,9 +103,7 @@ test_expect_failure REBASE_P \ test_expect_failure REBASE_P \ 'Rebase -Xsubtree --keep-empty --preserve-merges --onto empty commit' ' reset_rebase && - git checkout -b rebase-keep-empty-empty master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-keep-empty-empty to-rebase && git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && verbose test "$(commit_message HEAD)" = "Empty commit" ' @@ -117,9 +111,7 @@ test_expect_failure REBASE_P \ # FAILURE: fatal: Could not parse object test_expect_failure 'Rebase -Xsubtree --onto commit 4' ' reset_rebase && - git checkout -b rebase-onto-4 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-onto-4 to-rebase && git rebase -Xsubtree=files_subtree --onto files-master master && verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" ' @@ -127,18 +119,14 @@ test_expect_failure 'Rebase -Xsubtree --onto commit 4' ' # FAILURE: fatal: Could not parse object test_expect_failure 'Rebase -Xsubtree --onto commit 5' ' reset_rebase && - git checkout -b rebase-onto-5 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-onto-5 to-rebase && git rebase -Xsubtree=files_subtree --onto files-master master && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" ' # FAILURE: fatal: Could not parse object test_expect_failure 'Rebase -Xsubtree --onto empty commit' ' reset_rebase && - git checkout -b rebase-onto-empty master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-onto-empty to-rebase && git rebase -Xsubtree=files_subtree --onto files-master master && verbose test "$(commit_message HEAD)" = "Empty commit" ' -- cgit v1.2.3 From b8c6f24255d3224438ee8c591b7b08d665433b6b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:44 -0700 Subject: t3427: condense the unnecessarily repetitive test cases into three Previously, this test script performed essentially three rebases and verified breakages by testing the post-rebase commits' messages. To do so, the rebases were performed multiple times, though, once per commit message to test. This wastes electricity (and CO2) and time. Let's condense the test cases to the essential number: the number of different rebases to validate. On Windows, where the scripted nature of the `--preserve-merges` backend hurts performance rather badly, this reduces the overall runtime in this developer's setup from ~1m to ~28s while still performing the exact same testing as before. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 61 +++++++++-------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 64ba95f3e0..b21925d279 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -64,70 +64,31 @@ test_expect_success 'setup' ' ' # FAILURE: Does not preserve master4. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --preserve-merges --onto commit 4' ' +test_expect_failure REBASE_P 'Rebase -Xsubtree --preserve-merges --onto commit' ' reset_rebase && - git checkout -b rebase-preserve-merges-4 to-rebase && - git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~)" = "files_subtree/master4" -' - -# FAILURE: Does not preserve master5. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --preserve-merges --onto commit 5' ' - reset_rebase && - git checkout -b rebase-preserve-merges-5 to-rebase && + git checkout -b rebase-preserve-merges to-rebase && git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && + verbose test "$(commit_message HEAD~)" = "files_subtree/master4" && verbose test "$(commit_message HEAD)" = "files_subtree/master5" ' # FAILURE: Does not preserve master4. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 4' ' +test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit' ' reset_rebase && - git checkout -b rebase-keep-empty-4 to-rebase && - git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" -' - -# FAILURE: Does not preserve master5. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 5' ' - reset_rebase && - git checkout -b rebase-keep-empty-5 to-rebase && - git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~)" = "files_subtree/master5" -' - -# FAILURE: Does not preserve Empty. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --keep-empty --preserve-merges --onto empty commit' ' - reset_rebase && - git checkout -b rebase-keep-empty-empty to-rebase && + git checkout -b rebase-keep-empty to-rebase && git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && + verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" && + verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" ' # FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --onto commit 4' ' - reset_rebase && - git checkout -b rebase-onto-4 to-rebase && - git rebase -Xsubtree=files_subtree --onto files-master master && - verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" -' - -# FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --onto commit 5' ' - reset_rebase && - git checkout -b rebase-onto-5 to-rebase && - git rebase -Xsubtree=files_subtree --onto files-master master && - verbose test "$(commit_message HEAD~)" = "files_subtree/master5" -' -# FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --onto empty commit' ' +test_expect_failure 'Rebase -Xsubtree --onto commit' ' reset_rebase && - git checkout -b rebase-onto-empty to-rebase && + git checkout -b rebase-onto to-rebase && git rebase -Xsubtree=files_subtree --onto files-master master && + verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" && + verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" ' -- cgit v1.2.3 From a9c71073dace0d1ddbd12291604d191064b1ae94 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:45 -0700 Subject: t3427: fix erroneous assumption Apart from the `setup` test case, `t3427-rebase-subtree.sh` is made up exclusively of demonstrations of breakages. The tricky thing about such demonstrations is that they are often buggy themselves. In this instance, somewhere over the course of the six iterations of the patch that eventually made it into Git's `master` as 5f35900849e (contrib/subtree: Add a test for subtree rebase that loses commits, 2016-06-28), the commit message "files_subtree/master4" was changed to just "master4", but the test cases still expected the old commit message. Let's fix this, at long last. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index b21925d279..94cc532e10 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -68,7 +68,7 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --preserve-merges --onto commit' reset_rebase && git checkout -b rebase-preserve-merges to-rebase && git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~)" = "files_subtree/master4" && + verbose test "$(commit_message HEAD~)" = "master4" && verbose test "$(commit_message HEAD)" = "files_subtree/master5" ' @@ -77,7 +77,7 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges -- reset_rebase && git checkout -b rebase-keep-empty to-rebase && git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" && + verbose test "$(commit_message HEAD~2)" = "master4" && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" ' @@ -87,7 +87,7 @@ test_expect_failure 'Rebase -Xsubtree --onto commit' ' reset_rebase && git checkout -b rebase-onto to-rebase && git rebase -Xsubtree=files_subtree --onto files-master master && - verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" && + verbose test "$(commit_message HEAD~2)" = "master4" && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" ' -- cgit v1.2.3 From f67336dabf8b77f1eee0341790c8fbbe5c6d81dd Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:45 -0700 Subject: t3427: accommodate for the `rebase --merge` backend having been replaced Since 68aa495b590 (rebase: implement --merge via the interactive machinery, 2018-12-11), the job of the old `--merge` backend is now performed by the `--interactive` backend, too. One consequence is that empty commits are no longer rebased by default. Meaning that the test case that calls `git rebase -Xsubtree` (which used to be handled by the `--merge` backend) now needs to ask explicitly for the empty commit to be rebased. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 94cc532e10..a734716ea3 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -83,10 +83,10 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges -- ' # FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --onto commit' ' +test_expect_failure 'Rebase -Xsubtree --keep-empty --onto commit' ' reset_rebase && git checkout -b rebase-onto to-rebase && - git rebase -Xsubtree=files_subtree --onto files-master master && + git rebase -Xsubtree=files_subtree --keep-empty --onto files-master master && verbose test "$(commit_message HEAD~2)" = "master4" && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" -- cgit v1.2.3 From 4e6023b13ae1159277a7c3053f8d074c23456812 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:46 -0700 Subject: t3427: fix another incorrect assumption The test case that concerns `git rebase -Xsubtree` (with the default rebase backend, not with `--preserve-merges`) starts out with a pre-rebase commit history that begins with a commit that introduces three files: master1.t, master2.t and master3.t. This commit was generated by passing a subtree merge commit through `git filter-branch --subdirectory-filter`, so it looks as if this commit really introduces all those files. The commit history onto which this commit is then rebased, however, introduced those files in individual commits. For that reason, the rebase will fail, it _must_ fail, because the first `pick` results in no changes to be committed. Let's fix the test case to expect exactly this situation. With this change, we can mark the original bug that this test case tried to demonstrate as fixed. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index a734716ea3..7a37235768 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -82,11 +82,12 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges -- verbose test "$(commit_message HEAD)" = "Empty commit" ' -# FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --keep-empty --onto commit' ' +test_expect_success 'Rebase -Xsubtree --keep-empty --onto commit' ' reset_rebase && git checkout -b rebase-onto to-rebase && - git rebase -Xsubtree=files_subtree --keep-empty --onto files-master master && + test_must_fail git rebase -Xsubtree=files_subtree --keep-empty --onto files-master master && + : first pick results in no changes && + git rebase --continue && verbose test "$(commit_message HEAD~2)" = "master4" && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" -- cgit v1.2.3 From e145d993478befd0db6999822aa31d422b283a3b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:47 -0700 Subject: rebase -r: support merge strategies other than `recursive` We already support merge strategies in the sequencer, but only for `pick` commands. With this commit, we now also support them in `merge` commands. The approach is simple: if any merge strategy option is specified, or if any merge strategy other than `recursive` is specified, we simply spawn the `git merge` command. Otherwise, we handle the merge in-process just as before. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3422-rebase-incompatible-options.sh | 10 ---------- t/t3430-rebase-merges.sh | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 't') diff --git a/t/t3422-rebase-incompatible-options.sh b/t/t3422-rebase-incompatible-options.sh index a5868ea152..50e7960702 100755 --- a/t/t3422-rebase-incompatible-options.sh +++ b/t/t3422-rebase-incompatible-options.sh @@ -76,14 +76,4 @@ test_expect_success REBASE_P \ test_must_fail git rebase --preserve-merges --rebase-merges A ' -test_expect_success '--rebase-merges incompatible with --strategy' ' - git checkout B^0 && - test_must_fail git rebase --rebase-merges -s resolve A -' - -test_expect_success '--rebase-merges incompatible with --strategy-option' ' - git checkout B^0 && - test_must_fail git rebase --rebase-merges -Xignore-space-change A -' - test_done diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 42ba5b9f09..8ea6ff3548 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -412,4 +412,25 @@ test_expect_success '--continue after resolving conflicts after a merge' ' test_path_is_missing .git/MERGE_HEAD ' +test_expect_success '--rebase-merges with strategies' ' + git checkout -b with-a-strategy F && + test_tick && + git merge -m "Merge conflicting-G" conflicting-G && + + : first, test with a merge strategy option && + git rebase -ir -Xtheirs G && + echo conflicting-G >expect && + test_cmp expect G.t && + + : now, try with a merge strategy other than recursive && + git reset --hard @{1} && + write_script git-merge-override <<-\EOF && + echo overridden$1 >>G.t + git add G.t + EOF + PATH="$PWD:$PATH" git rebase -ir -s override -Xxopt G && + test_write_lines G overridden--xopt >expect && + test_cmp expect G.t +' + test_done -- cgit v1.2.3 From 5dcdd7409ad3b3e8d5e79871bfb9d5f4215d4a13 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:48 -0700 Subject: t/lib-rebase: prepare for testing `git rebase --rebase-merges` The format of the todo list is quite a bit different in the `--rebase-merges` mode; Let's prepare the fake editor to handle those todo lists properly, too. The original idea was that we keep the original command unless overridden, and because the original todo lists only had `pick` lines anyway, we could be sloppy and "override" the command by the same command (i.e. use the sed replacement pattern "pick" instead of "&"). This actually would not have worked with `fixup` and `squash` commands, but it would appear that we never tried to use the fake editor with `--autosquash`. However, in the next commit we want to use the fake editor in conjunction with `--rebase-merges`, so let's use the correct sed replacement pattern. Technically, it is not necessary to take care of the `fakesha` thing (where we reuse the sed replacement pattern to craft a new todo command), at least for now, as the only user of that thing overrides the `action` anyway. Nevertheless, for completeness' sake, we do take care of it. Helped-by: brian m. carlson Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/lib-rebase.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 't') diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 7ea30e5006..6d87961e41 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -44,10 +44,10 @@ set_fake_editor () { rm -f "$1" echo 'rebase -i script before editing:' cat "$1".tmp - action=pick + action=\& for line in $FAKE_LINES; do case $line in - pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d) + pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d|label|l|reset|r|merge|m) action="$line";; exec_*|x_*|break|b) echo "$line" | sed 's/_/ /g' >> "$1";; @@ -58,11 +58,12 @@ set_fake_editor () { bad) action="badcmd";; fakesha) + test \& != "$action" || action=pick echo "$action XXXXXXX False commit" >> "$1" action=pick;; *) - sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1" - action=pick;; + sed -n "${line}s/^[a-z][a-z]*/$action/p" < "$1".tmp >> "$1" + action=\&;; esac done echo 'rebase -i script after editing:' -- cgit v1.2.3 From a63f990d9205d1a781aec310e44edf35e29063a2 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:49 -0700 Subject: t3418: test `rebase -r` with merge strategies There is a test case in this script that verifies that `git rebase --preserve-merges` works all right with non-default merge strategies or non-default merge strategy options. Now that `git rebase --rebase-merges` learned about merge strategies, let's copy-edit this test case to verify that that works as intended, too. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3418-rebase-continue.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't') diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index bdaa511bb0..fbf9addfd1 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -120,6 +120,20 @@ test_expect_success REBASE_P 'rebase passes merge strategy options correctly' ' git rebase --continue ' +test_expect_success 'rebase -r passes merge strategy options correctly' ' + rm -fr .git/rebase-* && + git reset --hard commit-new-file-F3-on-topic-branch && + test_commit merge-theirs && + git reset --hard HEAD^ && + test_commit some-other-commit && + test_tick && + git merge --no-ff merge-theirs && + FAKE_LINES="1 3 edit 4 5 7 8 9" git rebase -i -f -r -m \ + -s recursive --strategy-option=theirs HEAD~2 && + test_commit force-change-ours && + git rebase --continue +' + test_expect_success '--skip after failed fixup cleans commit message' ' test_when_finished "test_might_fail git rebase --abort" && git checkout -b with-conflicting-fixup && -- cgit v1.2.3 From e1fac531ea9f9dc710f6eeae37ea2b38dd5f9fae Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 31 Jul 2019 08:18:49 -0700 Subject: rebase -r: do not (re-)generate root commits with `--root` *and* `--onto` When rebasing a complete commit history onto a given commit, it is pretty obvious that the root commits should be rebased on top of said given commit. To test this, let's kill two birds with one stone and add a test case to t3427-rebase-subtree.sh that not only demonstrates that this works, but also that `git rebase -r` works with merge strategies now. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 7a37235768..39e348de16 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -93,4 +93,15 @@ test_expect_success 'Rebase -Xsubtree --keep-empty --onto commit' ' verbose test "$(commit_message HEAD)" = "Empty commit" ' +test_expect_success 'Rebase -Xsubtree --keep-empty --rebase-merges --onto commit' ' + reset_rebase && + git checkout -b rebase-merges-onto to-rebase && + test_must_fail git rebase -Xsubtree=files_subtree --keep-empty --rebase-merges --onto files-master --root && + : first pick results in no changes && + git rebase --continue && + verbose test "$(commit_message HEAD~2)" = "master4" && + verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && + verbose test "$(commit_message HEAD)" = "Empty commit" +' + test_done -- cgit v1.2.3 From 476998d05bc62b9baaed240da0893ec5d80d676a Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Wed, 4 Sep 2019 14:40:48 -0700 Subject: t3427: accelerate this test by using fast-export and fast-import fast-export and fast-import can easily handle the simple rewrite that was being done by filter-branch, and should be faster on systems with a slow fork. Measuring the overall time taken for all of t3427 (not just the difference between filter-branch and fast-export/fast-import) shows a speedup of about 5% on Linux and 11% on Mac. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t3427-rebase-subtree.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 39e348de16..bec48e6a1f 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -59,7 +59,10 @@ test_expect_success 'setup' ' test_commit files_subtree/master5 && git checkout -b to-rebase && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && + git fast-export --no-data HEAD -- files_subtree/ | + sed -e "s%\([0-9a-f]\{40\} \)files_subtree/%\1%" | + git fast-import --force --quiet && + git reset --hard && git commit -m "Empty commit" --allow-empty ' -- cgit v1.2.3