for-each-ref: add new option to include root refs
[git.git] / t / t4133-apply-filenames.sh
blobc21ddb29466ec46b3441313ada2c36b3173067b7
1 #!/bin/sh
3 # Copyright (c) 2010 Andreas Gruenbacher
6 test_description='git apply filename consistency check'
9 TEST_PASSES_SANITIZE_LEAK=true
10 . ./test-lib.sh
12 test_expect_success setup '
13 cat > bad1.patch <<EOF &&
14 diff --git a/f b/f
15 new file mode 100644
16 index 0000000..d00491f
17 --- /dev/null
18 +++ b/f-blah
19 @@ -0,0 +1 @@
21 EOF
22 cat > bad2.patch <<EOF
23 diff --git a/f b/f
24 deleted file mode 100644
25 index d00491f..0000000
26 --- b/f-blah
27 +++ /dev/null
28 @@ -1 +0,0 @@
30 EOF
33 test_expect_success 'apply diff with inconsistent filenames in headers' '
34 test_must_fail git apply bad1.patch 2>err &&
35 test_grep "inconsistent new filename" err &&
36 test_must_fail git apply bad2.patch 2>err &&
37 test_grep "inconsistent old filename" err
40 test_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 @@
47 EOF
48 test_must_fail git apply missing_new_filename.diff 2>err &&
49 test_grep "lacks filename information" err
52 test_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 @@
59 EOF
60 test_must_fail git apply missing_old_filename.diff 2>err &&
61 test_grep "lacks filename information" err
64 test_done