4
5
. ./test-lib.sh
6
7
-count () {
8
- i=0
9
- while test $i -lt $1
10
- do
11
- echo "$i"
12
- i=$(($i+1))
13
- done
14
-}
15
-
7
scramble () {
8
i=0
9
while read x
17
mv -f "$1.new" "$1"
18
}
19
29
-run () {
30
- echo \$ "$@"
31
- /usr/bin/time "$@" >/dev/null
32
-}
33
-
20
test_expect_success 'setup' '
21
git commit --allow-empty -m initial &&
22
git tag root
23
'
24
39
-do_tests () {
40
- nlines=$1 pr=${2-}
41
-
42
- test_expect_success $pr "setup: $nlines lines" "
43
- rm -f .gitattributes &&
44
- git checkout -q -f master &&
45
- git reset --hard root &&
46
- count $nlines >file &&
47
- git add file &&
48
- git commit -q -m initial &&
49
- git branch -f other &&
50
-
51
- scramble file &&
52
- git add file &&
53
- git commit -q -m 'change big file' &&
54
-
55
- git checkout -q other &&
56
- : >newfile &&
57
- git add newfile &&
58
- git commit -q -m 'add small file' &&
59
-
60
- git cherry-pick master >/dev/null 2>&1
61
- "
62
-
63
- test_debug "
64
- run git diff master^\!
65
- "
66
-
67
- test_expect_success $pr 'setup attributes' "
68
- echo 'file binary' >.gitattributes
69
- "
70
-
71
- test_debug "
72
- run git format-patch --stdout master &&
73
- run git format-patch --stdout --ignore-if-in-upstream master
74
- "
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
76
- test_expect_success $pr 'detect upstream patch' '
77
- git checkout -q master &&
78
- scramble file &&
79
- git add file &&
80
- git commit -q -m "change big file again" &&
81
- git checkout -q other^{} &&
82
- git rebase master &&
83
- test_must_fail test -n "$(git rev-list master...HEAD~)"
84
- '
46
+test_expect_success 'setup attributes' '
47
+ echo "file binary" >.gitattributes
48
+'
49
86
- test_expect_success $pr 'do not drop patch' '
87
- git branch -f squashed master &&
88
- git checkout -q -f squashed &&
89
- git reset -q --soft HEAD~2 &&
90
- git commit -q -m squashed &&
91
- git checkout -q other^{} &&
92
- test_must_fail git rebase squashed &&
93
- git rebase --quit
94
- '
95
-}
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
+ test_must_fail test -n "$(git rev-list master...HEAD~)"
58
+'
59
97
-do_tests 500
98
-do_tests 50000 EXPENSIVE
60
+test_expect_success 'do not drop patch' '
61
+ git branch -f squashed master &&
62
+ git checkout -q -f squashed &&
63
+ git reset -q --soft HEAD~2 &&
64
+ git commit -q -m squashed &&
65
+ git checkout -q other^{} &&
66
+ test_must_fail git rebase squashed &&
67
+ git rebase --quit
68
+'
69
70
test_done