]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4118-apply-empty-context.sh
The third batch
[thirdparty/git.git] / t / t4118-apply-empty-context.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Junio C Hamano
4 #
5
6 test_description='git apply with new style GNU diff with empty context
7
8 '
9
10
11 TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
13
14 test_expect_success setup '
15 test_write_lines "" "" A B C "" >file1 &&
16 cat file1 >file1.orig &&
17 {
18 cat file1 &&
19 echo Q | tr -d "\\012"
20 } >file2 &&
21 cat file2 >file2.orig &&
22 git add file1 file2 &&
23 sed -e "/^B/d" <file1.orig >file1 &&
24 cat file1 > file2 &&
25 echo Q | tr -d "\\012" >>file2 &&
26 cat file1 >file1.mods &&
27 cat file2 >file2.mods &&
28 git diff |
29 sed -e "s/^ \$//" >diff.output
30 '
31
32 test_expect_success 'apply --numstat' '
33
34 git apply --numstat diff.output >actual &&
35 {
36 echo "0 1 file1" &&
37 echo "0 1 file2"
38 } >expect &&
39 test_cmp expect actual
40
41 '
42
43 test_expect_success 'apply --apply' '
44
45 cat file1.orig >file1 &&
46 cat file2.orig >file2 &&
47 git update-index file1 file2 &&
48 git apply --index diff.output &&
49 test_cmp file1.mods file1 &&
50 test_cmp file2.mods file2
51 '
52
53 test_done