blob: 65f2e4c3efb9ae5b5459e15df337e07201d78c38 [file] [log] [blame]
Linus Torvaldsb507b462006-10-19 19:26:08 -07001#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
Junio C Hamano5be60072007-07-02 22:52:14 -07006test_description='git apply with new style GNU diff with empty context
Linus Torvaldsb507b462006-10-19 19:26:08 -07007
8'
9
10. ./test-lib.sh
11
12test_expect_success setup '
13 {
14 echo; echo;
15 echo A; echo B; echo C;
16 echo;
17 } >file1 &&
18 cat file1 >file1.orig &&
19 {
20 cat file1 &&
21 echo Q | tr -d "\\012"
22 } >file2 &&
Brandon Casey72357042009-05-06 13:29:14 -050023 cat file2 >file2.orig &&
Linus Torvaldsb507b462006-10-19 19:26:08 -070024 git add file1 file2 &&
25 sed -e "/^B/d" <file1.orig >file1 &&
Brandon Casey325fb152009-05-06 13:29:15 -050026 cat file1 > file2 &&
Johannes Schindelin3007a782007-03-22 21:05:28 -040027 echo Q | tr -d "\\012" >>file2 &&
Linus Torvaldsb507b462006-10-19 19:26:08 -070028 cat file1 >file1.mods &&
29 cat file2 >file2.mods &&
30 git diff |
31 sed -e "s/^ \$//" >diff.output
32'
33
34test_expect_success 'apply --numstat' '
35
36 git apply --numstat diff.output >actual &&
37 {
38 echo "0 1 file1" &&
39 echo "0 1 file2"
40 } >expect &&
Junio C Hamano3af82862008-05-23 22:28:56 -070041 test_cmp expect actual
Linus Torvaldsb507b462006-10-19 19:26:08 -070042
43'
44
45test_expect_success 'apply --apply' '
46
47 cat file1.orig >file1 &&
48 cat file2.orig >file2 &&
49 git update-index file1 file2 &&
50 git apply --index diff.output &&
Junio C Hamano3af82862008-05-23 22:28:56 -070051 test_cmp file1.mods file1 &&
52 test_cmp file2.mods file2
Linus Torvaldsb507b462006-10-19 19:26:08 -070053'
54
55test_done