]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3419-rebase-patch-id.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t3419-rebase-patch-id.sh
CommitLineData
00f66f0e 1#!/bin/sh
beb17217
CB
2
3test_description='git rebase - test patch id computation'
4
d1c02d93 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
9ff2f060 8TEST_PASSES_SANITIZE_LEAK=true
beb17217
CB
9. ./test-lib.sh
10
b687cd6a 11scramble () {
beb17217
CB
12 i=0
13 while read x
14 do
15 if test $i -ne 0
16 then
17 echo "$x"
18 fi
00f66f0e 19 i=$((($i+1) % 10))
b687cd6a 20 done <"$1" >"$1.new"
beb17217
CB
21 mv -f "$1.new" "$1"
22}
23
beb17217 24test_expect_success 'setup' '
02380389 25 git commit --allow-empty -m initial &&
beb17217
CB
26 git tag root
27'
28
bb2dbe30
JK
29test_expect_success 'setup: 500 lines' '
30 rm -f .gitattributes &&
d1c02d93 31 git checkout -q -f main &&
bb2dbe30
JK
32 git reset --hard root &&
33 test_seq 500 >file &&
34 git add file &&
35 git commit -q -m initial &&
36 git branch -f other &&
37
38 scramble file &&
39 git add file &&
40 git commit -q -m "change big file" &&
41
42 git checkout -q other &&
43 : >newfile &&
44 git add newfile &&
45 git commit -q -m "add small file" &&
46
0570be79 47 git cherry-pick main >/dev/null 2>&1 &&
beb17217 48
0570be79
JZ
49 git branch -f squashed main &&
50 git checkout -q -f squashed &&
51 git reset -q --soft HEAD~2 &&
93105aba
JZ
52 git commit -q -m squashed &&
53
54 git branch -f mode main &&
55 git checkout -q -f mode &&
56 test_chmod +x file &&
57 git commit -q -a --amend &&
58
59 git branch -f modeother other &&
60 git checkout -q -f modeother &&
61 test_chmod +x file &&
62 git commit -q -a --amend
bb2dbe30 63'
beb17217 64
bb2dbe30 65test_expect_success 'detect upstream patch' '
0570be79 66 git checkout -q main^{} &&
bb2dbe30
JK
67 scramble file &&
68 git add file &&
69 git commit -q -m "change big file again" &&
70 git checkout -q other^{} &&
d1c02d93
JS
71 git rebase main &&
72 git rev-list main...HEAD~ >revs &&
21e3bb12 73 test_must_be_empty revs
bb2dbe30 74'
beb17217 75
0570be79
JZ
76test_expect_success 'detect upstream patch binary' '
77 echo "file binary" >.gitattributes &&
78 git checkout -q other^{} &&
79 git rebase main &&
80 git rev-list main...HEAD~ >revs &&
81 test_must_be_empty revs &&
82 test_when_finished "rm .gitattributes"
83'
84
93105aba
JZ
85test_expect_success 'detect upstream patch modechange' '
86 git checkout -q modeother^{} &&
87 git rebase mode &&
88 git rev-list mode...HEAD~ >revs &&
89 test_must_be_empty revs
90'
91
bb2dbe30 92test_expect_success 'do not drop patch' '
bb2dbe30
JK
93 git checkout -q other^{} &&
94 test_must_fail git rebase squashed &&
0570be79
JZ
95 test_when_finished "git rebase --abort"
96'
97
98test_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"
bb2dbe30 104'
beb17217 105
93105aba
JZ
106test_expect_success 'do not drop patch modechange' '
107 git checkout -q modeother^{} &&
108 git rebase other &&
109 cat >expected <<-\EOF &&
110 diff --git a/file b/file
111 old mode 100644
112 new mode 100755
113 EOF
114 git diff HEAD~ >modediff &&
115 test_cmp expected modediff
116'
117
beb17217 118test_done