decorate: add clear_decoration() function
[git.git] / t / t3419-rebase-patch-id.sh
blob6c61f240cf9874bbdb0190739b66a1c0ed99289f
1 #!/bin/sh
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
9 . ./test-lib.sh
11 scramble () {
12 i=0
13 while read x
15 if test $i -ne 0
16 then
17 echo "$x"
19 i=$((($i+1) % 10))
20 done <"$1" >"$1.new"
21 mv -f "$1.new" "$1"
24 test_expect_success 'setup' '
25 git commit --allow-empty -m initial &&
26 git tag root
29 test_expect_success 'setup: 500 lines' '
30 rm -f .gitattributes &&
31 git checkout -q -f main &&
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 &&
38 scramble file &&
39 git add file &&
40 git commit -q -m "change big file" &&
42 git checkout -q other &&
43 : >newfile &&
44 git add newfile &&
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 &&
56 test_chmod +x file &&
57 git commit -q -a --amend &&
59 git branch -f modeother other &&
60 git checkout -q -f modeother &&
61 test_chmod +x file &&
62 git commit -q -a --amend
65 test_expect_success 'detect upstream patch' '
66 git checkout -q main^{} &&
67 scramble file &&
68 git add file &&
69 git commit -q -m "change big file again" &&
70 git checkout -q other^{} &&
71 git rebase main &&
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^{} &&
79 git rebase main &&
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^{} &&
87 git rebase mode &&
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^{} &&
108 git rebase other &&
109 cat >expected <<-\EOF &&
110 diff --git a/file b/file
111 old mode 100644
112 new mode 100755
114 git diff HEAD~ >modediff &&
115 test_cmp expected modediff
118 test_done