]>
Commit | Line | Data |
---|---|---|
2c93286a JM |
1 | #!/bin/sh |
2 | ||
3 | test_description='git am with corrupt input' | |
4 | . ./test-lib.sh | |
5 | ||
2c93286a | 6 | test_expect_success setup ' |
ddeaf7ef SG |
7 | # Note the missing "+++" line: |
8 | cat >bad-patch.diff <<-\EOF && | |
9 | From: A U Thor <au.thor@example.com> | |
10 | diff --git a/f b/f | |
11 | index 7898192..6178079 100644 | |
12 | --- a/f | |
13 | @@ -1 +1 @@ | |
14 | -a | |
15 | +b | |
16 | EOF | |
17 | ||
18 | echo a >f && | |
2c93286a JM |
19 | git add f && |
20 | test_tick && | |
21 | git commit -m initial | |
22 | ' | |
23 | ||
24 | # This used to fail before, too, but with a different diagnostic. | |
25 | # fatal: unable to write file '(null)' mode 100644: Bad address | |
26 | # Also, it had the unwanted side-effect of deleting f. | |
27 | test_expect_success 'try to apply corrupted patch' ' | |
431bb23a | 28 | test_must_fail git -c advice.amWorkDir=false am bad-patch.diff 2>actual |
2c93286a JM |
29 | ' |
30 | ||
2c93286a | 31 | test_expect_success 'compare diagnostic; ensure file is still here' ' |
5950851e | 32 | echo "error: git diff header lacks filename information (line 4)" >expected && |
ddeaf7ef | 33 | test_path_is_file f && |
f25dfb5e | 34 | test_i18ncmp expected actual |
2c93286a JM |
35 | ' |
36 | ||
37 | test_done |