mirror of
https://github.com/git/git.git
synced 2024-11-14 13:13:01 +01:00
cc64b318f2
When git apply is passed something that is not a patch, it does not produce an error message or exit with a non-zero status if it was not actually "applying" the patch i.e. --check or --numstat etc were supplied on the command line. Fix this by producing an error when apply fails to find any hunks whatsoever while parsing the patch. This will cause some of the output formats (--numstat, --diffstat, etc) to produce an error when they formerly would have reported zero changes and exited successfully. That seems like the correct behavior though. Failure to recognize the input as a patch should be an error. Plus, add a test. Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
19 lines
359 B
Bash
Executable file
19 lines
359 B
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='git apply should exit non-zero with unrecognized input.'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_commit 1
|
|
'
|
|
|
|
test_expect_success 'apply --check exits non-zero with unrecognized input' '
|
|
test_must_fail git apply --check - <<-\EOF
|
|
I am not a patch
|
|
I look nothing like a patch
|
|
git apply must fail
|
|
EOF
|
|
'
|
|
|
|
test_done
|