3 # Copyright (c) 2006 Junio C Hamano
6 test_description='Format-patch skipping already incorporated patches'
10 test_expect_success setup '
12 for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
15 git commit -m Initial &&
16 git checkout -b side &&
18 for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file &&
20 git update-index file elif &&
21 git update-index --chmod=+x elif &&
22 git commit -m "Side changes #1" &&
24 for i in D E F; do echo "$i"; done >>file &&
25 git update-index file &&
26 git commit -m "Side changes #2" &&
29 for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file &&
30 git update-index file &&
31 git commit -m "Side changes #3 with \\n backslash-n in it." &&
33 git checkout master &&
34 git diff-tree -p C2 | git apply --index &&
35 git commit -m "Master accepts moral equivalent of #2"
39 test_expect_success "format-patch --ignore-if-in-upstream" '
41 git format-patch --stdout master..side >patch0 &&
42 cnt=`grep "^From " patch0 | wc -l` &&
47 test_expect_success "format-patch --ignore-if-in-upstream" '
49 git format-patch --stdout \
50 --ignore-if-in-upstream master..side >patch1 &&
51 cnt=`grep "^From " patch1 | wc -l` &&
56 test_expect_success "format-patch result applies" '
58 git checkout -b rebuild-0 master &&
60 cnt=`git rev-list master.. | wc -l` &&
64 test_expect_success "format-patch --ignore-if-in-upstream result applies" '
66 git checkout -b rebuild-1 master &&
68 cnt=`git rev-list master.. | wc -l` &&
72 test_expect_success 'commit did not screw up the log message' '
74 git cat-file commit side | grep "^Side .* with .* backslash-n"
78 test_expect_success 'format-patch did not screw up the log message' '
80 grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
81 grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
85 test_expect_success 'replay did not screw up the log message' '
87 git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"