Code

Merge branch 'da/difftool-test'
[git.git] / t / t3419-rebase-patch-id.sh
1 #!/bin/sh
3 test_description='git rebase - test patch id computation'
5 . ./test-lib.sh
7 test_set_prereq NOT_EXPENSIVE
8 test -n "$GIT_PATCHID_TIMING_TESTS" && test_set_prereq EXPENSIVE
9 test -x /usr/bin/time && test_set_prereq USR_BIN_TIME
11 count()
12 {
13         i=0
14         while test $i -lt $1
15         do
16                 echo "$i"
17                 i=$(($i+1))
18         done
19 }
21 scramble()
22 {
23         i=0
24         while read x
25         do
26                 if test $i -ne 0
27                 then
28                         echo "$x"
29                 fi
30                 i=$((($i+1) % 10))
31         done < "$1" > "$1.new"
32         mv -f "$1.new" "$1"
33 }
35 run()
36 {
37         echo \$ "$@"
38         /usr/bin/time "$@" >/dev/null
39 }
41 test_expect_success 'setup' '
42         git commit --allow-empty -m initial &&
43         git tag root
44 '
46 do_tests()
47 {
48         pr=$1
49         nlines=$2
51         test_expect_success $pr "setup: $nlines lines" "
52                 rm -f .gitattributes &&
53                 git checkout -q -f master &&
54                 git reset --hard root &&
55                 count $nlines >file &&
56                 git add file &&
57                 git commit -q -m initial &&
58                 git branch -f other &&
60                 scramble file &&
61                 git add file &&
62                 git commit -q -m 'change big file' &&
64                 git checkout -q other &&
65                 : >newfile &&
66                 git add newfile &&
67                 git commit -q -m 'add small file' &&
69                 git cherry-pick master >/dev/null 2>&1
70         "
72         test_debug "
73                 run git diff master^\!
74         "
76         test_expect_success $pr 'setup attributes' "
77                 echo 'file binary' >.gitattributes
78         "
80         test_debug "
81                 run git format-patch --stdout master &&
82                 run git format-patch --stdout --ignore-if-in-upstream master
83         "
85         test_expect_success $pr 'detect upstream patch' "
86                 git checkout -q master &&
87                 scramble file &&
88                 git add file &&
89                 git commit -q -m 'change big file again' &&
90                 git checkout -q other^{} &&
91                 git rebase master &&
92                 test_must_fail test -n \"\$(git rev-list master...HEAD~)\"
93         "
95         test_expect_success $pr 'do not drop patch' "
96                 git branch -f squashed master &&
97                 git checkout -q -f squashed &&
98                 git reset -q --soft HEAD~2 &&
99                 git commit -q -m squashed &&
100                 git checkout -q other^{} &&
101                 test_must_fail git rebase squashed &&
102                 rm -rf .git/rebase-apply
103         "
106 do_tests NOT_EXPENSIVE 500
107 do_tests EXPENSIVE 50000
109 test_done