]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4133-apply-filenames.sh
t2104: style fixes
[thirdparty/git.git] / t / t4133-apply-filenames.sh
CommitLineData
da915939
AG
1#!/bin/sh
2#
3# Copyright (c) 2010 Andreas Gruenbacher
4#
5
6test_description='git apply filename consistency check'
7
f54f48fc
ÆAB
8
9TEST_PASSES_SANITIZE_LEAK=true
da915939
AG
10. ./test-lib.sh
11
12test_expect_success setup '
a48fcd83 13 cat > bad1.patch <<EOF &&
da915939
AG
14diff --git a/f b/f
15new file mode 100644
16index 0000000..d00491f
17--- /dev/null
18+++ b/f-blah
19@@ -0,0 +1 @@
20+1
21EOF
22 cat > bad2.patch <<EOF
23diff --git a/f b/f
24deleted file mode 100644
25index d00491f..0000000
26--- b/f-blah
27+++ /dev/null
28@@ -1 +0,0 @@
29-1
30EOF
31'
32
33test_expect_success 'apply diff with inconsistent filenames in headers' '
a48fcd83 34 test_must_fail git apply bad1.patch 2>err &&
6789275d 35 test_grep "inconsistent new filename" err &&
a48fcd83 36 test_must_fail git apply bad2.patch 2>err &&
6789275d 37 test_grep "inconsistent old filename" err
da915939
AG
38'
39
42699741
RS
40test_expect_success 'apply diff with new filename missing from headers' '
41 cat >missing_new_filename.diff <<-\EOF &&
42 diff --git a/f b/f
43 index 0000000..d00491f
44 --- a/f
45 @@ -0,0 +1 @@
46 +1
47 EOF
48 test_must_fail git apply missing_new_filename.diff 2>err &&
6789275d 49 test_grep "lacks filename information" err
42699741
RS
50'
51
52test_expect_success 'apply diff with old filename missing from headers' '
53 cat >missing_old_filename.diff <<-\EOF &&
54 diff --git a/f b/f
55 index d00491f..0000000
56 +++ b/f
57 @@ -1 +0,0 @@
58 -1
59 EOF
60 test_must_fail git apply missing_old_filename.diff 2>err &&
6789275d 61 test_grep "lacks filename information" err
42699741
RS
62'
63
da915939 64test_done