{"thread":{"id":"47934","subject":"[PATCH] test case highlighting possible strategy to rebase merge","startedAt":"2018-02-27T08:10:44Z","lastAt":"2018-02-27T08:10:44Z","messageCount":1,"participants":["Jacob Keller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"340386","messageId":"1519719029-19141-1-git-send-email-jacob.keller@gmail.com","threadId":"47934","inReplyTo":null,"subject":"[PATCH] test case highlighting possible strategy to rebase merge","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2018-02-27T08:10:29Z","receivedAt":"2018-02-27T08:10:44Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"Add a test case highlighting how the process outlined by Sergey Organov\ncould be used to re-create merges without losing any context.\n\nThe test currently only uses new files, with the exception of one part\ninvolving an evil merge. Unfortunately I'm not sure how to represent\nmerge conflicts that need to be handled. It looks like it should when\nthere is enough context that the changes don't have direct textual\nconflict, but I was unable to figure out how to produce such a change\ndirectly in the test case.\n\nI think this method shows a lot of promise, and is worth investigating\nmore to see if we can actually make it work in practice without\nrequiring separate steps.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n t/t7900-rebasing-merge.sh | 178 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 178 insertions(+)\n create mode 100755 t/t7900-rebasing-merge.sh\n\ndiff --git a/t/t7900-rebasing-merge.sh b/t/t7900-rebasing-merge.sh\nnew file mode 100755\nindex 0000000..7639425\n--- /dev/null\n+++ b/t/t7900-rebasing-merge.sh\n@@ -0,0 +1,178 @@\n+#!/bin/sh\n+\n+test_description='test showcasing safe method to rebase a merge'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\techo \"file1\" >a &&\n+\techo \"file2\" >b &&\n+\ttest_tick &&\n+\tgit add a b &&\n+\tgit commit -m \"initial\" &&\n+\tgit branch initial &&\n+\tgit branch branch1 &&\n+\tgit branch branch2 &&\n+\tgit checkout branch1 &&\n+\ttest_tick &&\n+\techo \"a change in file1\" >>a &&\n+\tgit add a &&\n+\tgit commit -m \"commit1\" &&\n+\ttest_tick &&\n+\techo \"another change in file1\" >>a &&\n+\tgit add a &&\n+\tgit commit -m \"commit2\" &&\n+\tgit checkout branch2 &&\n+\ttest_tick &&\n+\techo \"a change in file2\" >>b &&\n+\tgit add b &&\n+\tgit commit -m \"commit3\" &&\n+\tgit checkout -B simple-merge branch1 &&\n+\tgit merge -m \"simple merge branch2 into branch1\" branch2 &&\n+\tcat >expected <<-\\EOF &&\n+\tfile1\n+\ta change in file1\n+\tanother change in file1\n+\tEOF\n+\ttest_cmp expected a &&\n+\tcat >expected <<-\\EOF &&\n+\tfile2\n+\ta change in file2\n+\tEOF\n+\ttest_cmp expected b\n+'\n+\n+test_expect_success 'trivial rebase case' '\n+\tgit checkout -B new-initial initial &&\n+\techo \"newfile3\" >c &&\n+\ttest_tick &&\n+\tgit add c &&\n+\tgit commit -m \"a new file\" &&\n+\tgit checkout -B new-branch1 branch1 &&\n+\ttest_tick &&\n+\tgit rebase new-initial &&\n+\ttest_tick &&\n+\tgit cherry-pick -m1 --keep-redundant-commits simple-merge &&\n+\tgit checkout -B new-branch2 branch2 &&\n+\ttest_tick &&\n+\tgit rebase new-initial &&\n+\ttest_tick &&\n+\tgit cherry-pick -m2 --keep-redundant-commits simple-merge &&\n+\tgit checkout -B rebased-simple-merge new-branch1 &&\n+\tgit merge --no-ff -m \"rebased simple merge new-branch2 into new-branch1\" new-branch2 &&\n+\tgit reset --soft HEAD^ &&\n+\tgit update-ref refs/heads/rebased-simple-merge \"$(git commit-tree -m \"finalized rebased simple merge new-branch2 into new-branch1\" \"$(git write-tree)\" -p \"$(git rev-parse new-branch1^)\" -p \"$(git rev-parse new-branch2^)\")\" &&\n+\tgit checkout rebased-simple-merge &&\n+\tcat >expected <<-\\EOF &&\n+\tfile1\n+\ta change in file1\n+\tanother change in file1\n+\tEOF\n+\ttest_cmp expected a &&\n+\tcat >expected <<-\\EOF &&\n+\tfile2\n+\ta change in file2\n+\tEOF\n+\ttest_cmp expected b &&\n+\tcat >expected <<-\\EOF &&\n+\tnewfile3\n+\tEOF\n+\ttest_cmp expected c\n+'\n+\n+test_expect_success 'evil merge rebase case' '\n+\tgit checkout -B evil-merge simple-merge &&\n+\ttest_tick &&\n+\techo \"evil change to file2\" >>b &&\n+\tgit add b &&\n+\tgit commit --amend -m \"evil mergbe branch2 into branch1\" &&\n+\tgit checkout -B new-initial initial &&\n+\techo \"newfile3\" >c &&\n+\ttest_tick &&\n+\tgit add c &&\n+\tgit commit -m \"a new file\" &&\n+\tgit checkout -B new-branch1 branch1 &&\n+\ttest_tick &&\n+\tgit rebase new-initial &&\n+\ttest_tick &&\n+\tgit cherry-pick -m1 --keep-redundant-commits evil-merge &&\n+\tgit checkout -B new-branch2 branch2 &&\n+\ttest_tick &&\n+\tgit rebase new-initial &&\n+\ttest_tick &&\n+\tgit cherry-pick -m2 --keep-redundant-commits evil-merge &&\n+\tgit checkout -B rebased-evil-merge new-branch1 &&\n+\tgit merge --no-ff -m \"rebased simple merge new-branch2 into new-branch1\" new-branch2 &&\n+\tgit reset --soft HEAD^ &&\n+\tgit update-ref refs/heads/rebased-evil-merge \"$(git commit-tree -m \"finalized rebased simple merge new-branch2 into new-branch1\" \"$(git write-tree)\" -p \"$(git rev-parse new-branch1^)\" -p \"$(git rev-parse new-branch2^)\")\" &&\n+\tgit checkout rebased-evil-merge &&\n+\tcat >expected <<-\\EOF &&\n+\tfile1\n+\ta change in file1\n+\tanother change in file1\n+\tEOF\n+\ttest_cmp expected a &&\n+\tcat >expected <<-\\EOF &&\n+\tfile2\n+\ta change in file2\n+\tevil change to file2\n+\tEOF\n+\ttest_cmp expected b &&\n+\tcat >expected <<-\\EOF &&\n+\tnewfile3\n+\tEOF\n+\ttest_cmp expected c\n+'\n+test_expect_success 'rebase add commit to branch1 case' '\n+\tgit checkout -B new-initial initial &&\n+\techo \"newfile3\" >c &&\n+\ttest_tick &&\n+\tgit add c &&\n+\tgit commit -m \"a new file\" &&\n+\tgit checkout -B new-branch1 branch1 &&\n+\ttest_tick &&\n+\tgit rebase new-initial &&\n+\ttest_tick &&\n+\tcat >d <<-\\EOF &&\n+\trebasefile4\n+\ta new file added in rebase\n+\tEOF\n+\tgit add d &&\n+\tgit commit -m \"a new commit added to branch1\" &&\n+\ttest_tick &&\n+\tgit cherry-pick -m1 --keep-redundant-commits simple-merge &&\n+\tgit checkout -B new-branch2 branch2 &&\n+\ttest_tick &&\n+\tgit rebase new-initial &&\n+\ttest_tick &&\n+\tgit cherry-pick -m2 --keep-redundant-commits simple-merge &&\n+\tgit checkout -B rebased-add-commit-merge new-branch1 &&\n+\tgit merge --no-ff -m \"rebased add commit merge new-branch2 into new-branch1\" new-branch2 &&\n+\tgit reset --soft HEAD^ &&\n+\tgit update-ref refs/heads/rebased-add-commit-merge \"$(git commit-tree -m \"finalized rebased add commit merge new-branch2 into new-branch1\" \"$(git write-tree)\" -p \"$(git rev-parse new-branch1^)\" -p \"$(git rev-parse new-branch2^)\")\" &&\n+\tgit checkout rebased-add-commit-merge &&\n+\tcat >expected <<-\\EOF &&\n+\tfile1\n+\ta change in file1\n+\tanother change in file1\n+\tEOF\n+\ttest_cmp expected a &&\n+\tcat >expected <<-\\EOF &&\n+\tfile2\n+\ta change in file2\n+\tEOF\n+\ttest_cmp expected b &&\n+\tcat >expected <<-\\EOF &&\n+\tnewfile3\n+\tEOF\n+\ttest_cmp expected c &&\n+\tcat >expected <<-\\EOF &&\n+\trebasefile4\n+\ta new file added in rebase\n+\tEOF\n+\ttest_cmp expected d\n+'\n+\n+test_done\n+\n+\n-- \n2.7.4\n\n"}]}