packv4: nth_packed_object_sha1() packv4 support
[git/packv4.git] / t / t4014-format-patch.sh
blobdf969bb69ce148f26709691fe846def7f960d39d
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 changes #1" &&
21 for i in D E F; do echo "$i"; done >>file &&
22 git update-index file &&
23 git commit -m "Side changes #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 changes #3 with \\n backslash-n in it." &&
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_expect_success 'commit did not screw up the log message' '
71 git cat-file commit side | grep "^Side .* with .* backslash-n"
75 test_expect_success 'format-patch did not screw up the log message' '
77 grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
78 grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
82 test_expect_success 'replay did not screw up the log message' '
84 git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
88 test_done