interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t4133-apply-filenames.sh

63 lines · 1311 bytes Raw Blame History
1#!/bin/sh
2#
3# Copyright (c) 2010 Andreas Gruenbacher
4#
5
6test_description='git apply filename consistency check'
7
8
9. ./test-lib.sh
10
11test_expect_success setup '
12 cat > bad1.patch <<EOF &&
13diff --git a/f b/f
14new file mode 100644
15index 0000000..d00491f
16--- /dev/null
17+++ b/f-blah
18@@ -0,0 +1 @@
19+1
20EOF
21 cat > bad2.patch <<EOF
22diff --git a/f b/f
23deleted file mode 100644
24index d00491f..0000000
25--- b/f-blah
26+++ /dev/null
27@@ -1 +0,0 @@
28-1
29EOF
30'
31
32test_expect_success 'apply diff with inconsistent filenames in headers' '
33 test_must_fail git apply bad1.patch 2>err &&
34 test_grep "inconsistent new filename" err &&
35 test_must_fail git apply bad2.patch 2>err &&
36 test_grep "inconsistent old filename" err
37'
38
39test_expect_success 'apply diff with new filename missing from headers' '
40 cat >missing_new_filename.diff <<-\EOF &&
41 diff --git a/f b/f
42 index 0000000..d00491f
43 --- a/f
44 @@ -0,0 +1 @@
45 +1
46 EOF
47 test_must_fail git apply missing_new_filename.diff 2>err &&
48 test_grep "lacks filename information" err
49'
50
51test_expect_success 'apply diff with old filename missing from headers' '
52 cat >missing_old_filename.diff <<-\EOF &&
53 diff --git a/f b/f
54 index d00491f..0000000
55 +++ b/f
56 @@ -1 +0,0 @@
57 -1
58 EOF
59 test_must_fail git apply missing_old_filename.diff 2>err &&
60 test_grep "lacks filename information" err
61'
62
63test_done