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