Merge branch 'maint'
[git/jnareb-git.git] / t / t4014-format-patch.sh
blob4795872a776e3ccc7cc904b12c0352aae782f502
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='Format-patch skipping already incorporated patches'
8 . ./test-lib.sh
10 test_expect_success setup '
12 for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
13 git add file &&
14 git commit -m Initial &&
15 git checkout -b side &&
17 for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file &&
18 git update-index file &&
19 git commit -m "Side change #1" &&
21 for i in D E F; do echo "$i"; done >>file &&
22 git update-index file &&
23 git commit -m "Side change #2" &&
24 git tag C2 &&
26 for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file &&
27 git update-index file &&
28 git commit -m "Side change #3" &&
30 git checkout master &&
31 git diff-tree -p C2 | git apply --index &&
32 git commit -m "Master accepts moral equivalent of #2"
36 test_expect_success "format-patch --ignore-if-in-upstream" '
38 git format-patch --stdout master..side >patch0 &&
39 cnt=`grep "^From " patch0 | wc -l` &&
40 test $cnt = 3
44 test_expect_success "format-patch --ignore-if-in-upstream" '
46 git format-patch --stdout \
47 --ignore-if-in-upstream master..side >patch1 &&
48 cnt=`grep "^From " patch1 | wc -l` &&
49 test $cnt = 2
53 test_expect_success "format-patch result applies" '
55 git checkout -b rebuild-0 master &&
56 git am -3 patch0 &&
57 cnt=`git rev-list master.. | wc -l` &&
58 test $cnt = 2
61 test_expect_success "format-patch --ignore-if-in-upstream result applies" '
63 git checkout -b rebuild-1 master &&
64 git am -3 patch1 &&
65 cnt=`git rev-list master.. | wc -l` &&
66 test $cnt = 2
69 test_done