git-svn: delay term initialization
[git/gitweb.git] / t / t3419-rebase-patch-id.sh
blob9292b499f39925b6832bccd826fb43a8818f155a
1 #!/bin/sh
3 test_description='git rebase - test patch id computation'
5 . ./test-lib.sh
7 test -n "$GIT_PATCHID_TIMING_TESTS" && test_set_prereq EXPENSIVE
9 count () {
10 i=0
11 while test $i -lt $1
13 echo "$i"
14 i=$(($i+1))
15 done
18 scramble () {
19 i=0
20 while read x
22 if test $i -ne 0
23 then
24 echo "$x"
26 i=$((($i+1) % 10))
27 done <"$1" >"$1.new"
28 mv -f "$1.new" "$1"
31 run () {
32 echo \$ "$@"
33 /usr/bin/time "$@" >/dev/null
36 test_expect_success 'setup' '
37 git commit --allow-empty -m initial &&
38 git tag root
41 do_tests () {
42 nlines=$1 pr=${2-}
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 &&
53 scramble file &&
54 git add file &&
55 git commit -q -m 'change big file' &&
57 git checkout -q other &&
58 : >newfile &&
59 git add newfile &&
60 git commit -q -m 'add small file' &&
62 git cherry-pick master >/dev/null 2>&1
65 test_debug "
66 run git diff master^\!
69 test_expect_success $pr 'setup attributes' "
70 echo 'file binary' >.gitattributes
73 test_debug "
74 run git format-patch --stdout master &&
75 run git format-patch --stdout --ignore-if-in-upstream master
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~)\"
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
99 do_tests 500
100 do_tests 50000 EXPENSIVE
102 test_done