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
8 TEST_PASSES_SANITIZE_LEAK
=true
24 test_expect_success
'setup' '
25 git commit --allow-empty -m initial &&
29 test_expect_success
'setup: 500 lines' '
30 rm -f .gitattributes &&
31 git checkout -q -f main &&
32 git reset --hard root &&
35 git commit -q -m initial &&
36 git branch -f other &&
40 git commit -q -m "change big file" &&
42 git checkout -q other &&
45 git commit -q -m "add small file" &&
47 git cherry-pick main >/dev/null 2>&1 &&
49 git branch -f squashed main &&
50 git checkout -q -f squashed &&
51 git reset -q --soft HEAD~2 &&
52 git commit -q -m squashed &&
54 git branch -f mode main &&
55 git checkout -q -f mode &&
57 git commit -q -a --amend &&
59 git branch -f modeother other &&
60 git checkout -q -f modeother &&
62 git commit -q -a --amend
65 test_expect_success
'detect upstream patch' '
66 git checkout -q main^{} &&
69 git commit -q -m "change big file again" &&
70 git checkout -q other^{} &&
72 git rev-list main...HEAD~ >revs &&
73 test_must_be_empty revs
76 test_expect_success
'detect upstream patch binary' '
77 echo "file binary" >.gitattributes &&
78 git checkout -q other^{} &&
80 git rev-list main...HEAD~ >revs &&
81 test_must_be_empty revs &&
82 test_when_finished "rm .gitattributes"
85 test_expect_success
'detect upstream patch modechange' '
86 git checkout -q modeother^{} &&
88 git rev-list mode...HEAD~ >revs &&
89 test_must_be_empty revs
92 test_expect_success
'do not drop patch' '
93 git checkout -q other^{} &&
94 test_must_fail git rebase squashed &&
95 test_when_finished "git rebase --abort"
98 test_expect_success
'do not drop patch binary' '
99 echo "file binary" >.gitattributes &&
100 git checkout -q other^{} &&
101 test_must_fail git rebase squashed &&
102 test_when_finished "git rebase --abort" &&
103 test_when_finished "rm .gitattributes"
106 test_expect_success
'do not drop patch modechange' '
107 git checkout -q modeother^{} &&
109 cat >expected <<-\EOF &&
110 diff --git a/file b/file
114 git diff HEAD~ >modediff &&
115 test_cmp expected modediff