Imported Upstream version 2.27.0
[platform/upstream/git.git] / t / t3419-rebase-patch-id.sh
1 #!/bin/sh
2
3 test_description='git rebase - test patch id computation'
4
5 . ./test-lib.sh
6
7 scramble () {
8         i=0
9         while read x
10         do
11                 if test $i -ne 0
12                 then
13                         echo "$x"
14                 fi
15                 i=$((($i+1) % 10))
16         done <"$1" >"$1.new"
17         mv -f "$1.new" "$1"
18 }
19
20 test_expect_success 'setup' '
21         git commit --allow-empty -m initial &&
22         git tag root
23 '
24
25 test_expect_success 'setup: 500 lines' '
26         rm -f .gitattributes &&
27         git checkout -q -f master &&
28         git reset --hard root &&
29         test_seq 500 >file &&
30         git add file &&
31         git commit -q -m initial &&
32         git branch -f other &&
33
34         scramble file &&
35         git add file &&
36         git commit -q -m "change big file" &&
37
38         git checkout -q other &&
39         : >newfile &&
40         git add newfile &&
41         git commit -q -m "add small file" &&
42
43         git cherry-pick master >/dev/null 2>&1
44 '
45
46 test_expect_success 'setup attributes' '
47         echo "file binary" >.gitattributes
48 '
49
50 test_expect_success 'detect upstream patch' '
51         git checkout -q master &&
52         scramble file &&
53         git add file &&
54         git commit -q -m "change big file again" &&
55         git checkout -q other^{} &&
56         git rebase master &&
57         git rev-list master...HEAD~ >revs &&
58         test_must_be_empty revs
59 '
60
61 test_expect_success 'do not drop patch' '
62         git branch -f squashed master &&
63         git checkout -q -f squashed &&
64         git reset -q --soft HEAD~2 &&
65         git commit -q -m squashed &&
66         git checkout -q other^{} &&
67         test_must_fail git rebase squashed &&
68         git rebase --quit
69 '
70
71 test_done