3 test_description
='git rebase - test patch id computation'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
23 test_expect_success
'setup' '
24 git commit --allow-empty -m initial &&
28 test_expect_success
'setup: 500 lines' '
29 rm -f .gitattributes &&
30 git checkout -q -f main &&
31 git reset --hard root &&
34 git commit -q -m initial &&
35 git branch -f other &&
39 git commit -q -m "change big file" &&
41 git checkout -q other &&
44 git commit -q -m "add small file" &&
46 git cherry-pick main >/dev/null 2>&1 &&
48 git branch -f squashed main &&
49 git checkout -q -f squashed &&
50 git reset -q --soft HEAD~2 &&
51 git commit -q -m squashed &&
53 git branch -f mode main &&
54 git checkout -q -f mode &&
56 git commit -q -a --amend &&
58 git branch -f modeother other &&
59 git checkout -q -f modeother &&
61 git commit -q -a --amend
64 test_expect_success
'detect upstream patch' '
65 git checkout -q main^{} &&
68 git commit -q -m "change big file again" &&
69 git checkout -q other^{} &&
71 git rev-list main...HEAD~ >revs &&
72 test_must_be_empty revs
75 test_expect_success
'detect upstream patch binary' '
76 echo "file binary" >.gitattributes &&
77 git checkout -q other^{} &&
79 git rev-list main...HEAD~ >revs &&
80 test_must_be_empty revs &&
81 test_when_finished "rm .gitattributes"
84 test_expect_success
'detect upstream patch modechange' '
85 git checkout -q modeother^{} &&
87 git rev-list mode...HEAD~ >revs &&
88 test_must_be_empty revs
91 test_expect_success
'do not drop patch' '
92 git checkout -q other^{} &&
93 test_must_fail git rebase squashed &&
94 test_when_finished "git rebase --abort"
97 test_expect_success
'do not drop patch binary' '
98 echo "file binary" >.gitattributes &&
99 git checkout -q other^{} &&
100 test_must_fail git rebase squashed &&
101 test_when_finished "git rebase --abort" &&
102 test_when_finished "rm .gitattributes"
105 test_expect_success
'do not drop patch modechange' '
106 git checkout -q modeother^{} &&
108 cat >expected <<-\EOF &&
109 diff --git a/file b/file
113 git diff HEAD~ >modediff &&
114 test_cmp expected modediff