]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4014-format-patch.sh
Fix lapsus in builtin-apply.c
[thirdparty/git.git] / t / t4014-format-patch.sh
CommitLineData
ece3c67f
JH
1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='Format-patch skipping already incorporated patches'
7
8. ./test-lib.sh
9
10test_expect_success setup '
11
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 &&
16
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 &&
816366e2 19 git commit -m "Side changes #1" &&
ece3c67f
JH
20
21 for i in D E F; do echo "$i"; done >>file &&
22 git update-index file &&
816366e2 23 git commit -m "Side changes #2" &&
982b64e4 24 git tag C2 &&
ece3c67f
JH
25
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 &&
816366e2 28 git commit -m "Side changes #3 with \\n backslash-n in it." &&
ece3c67f
JH
29
30 git checkout master &&
982b64e4
JH
31 git diff-tree -p C2 | git apply --index &&
32 git commit -m "Master accepts moral equivalent of #2"
ece3c67f
JH
33
34'
35
36test_expect_success "format-patch --ignore-if-in-upstream" '
37
38 git format-patch --stdout master..side >patch0 &&
39 cnt=`grep "^From " patch0 | wc -l` &&
8780bd8f 40 test $cnt = 3
ece3c67f
JH
41
42'
43
44test_expect_success "format-patch --ignore-if-in-upstream" '
45
46 git format-patch --stdout \
47 --ignore-if-in-upstream master..side >patch1 &&
48 cnt=`grep "^From " patch1 | wc -l` &&
8780bd8f 49 test $cnt = 2
ece3c67f
JH
50
51'
52
53test_expect_success "format-patch result applies" '
54
55 git checkout -b rebuild-0 master &&
56 git am -3 patch0 &&
57 cnt=`git rev-list master.. | wc -l` &&
8780bd8f 58 test $cnt = 2
ece3c67f
JH
59'
60
61test_expect_success "format-patch --ignore-if-in-upstream result applies" '
62
63 git checkout -b rebuild-1 master &&
64 git am -3 patch1 &&
65 cnt=`git rev-list master.. | wc -l` &&
8780bd8f 66 test $cnt = 2
ece3c67f
JH
67'
68
816366e2
JH
69test_expect_success 'commit did not screw up the log message' '
70
71 git cat-file commit side | grep "^Side .* with .* backslash-n"
72
73'
74
75test_expect_success 'format-patch did not screw up the log message' '
76
77 grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
78 grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
79
80'
81
82test_expect_success 'replay did not screw up the log message' '
83
84 git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
85
86'
87
ece3c67f 88test_done