#!/bin/sh global test_description := ''git apply should exit non-zero with unrecognized input.'' source ./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_expect_success 'apply exits non-zero with no-op patch' ' cat >input <<-\EOF && diff --get a/1 b/1 index 6696ea4..606eddd 100644 --- a/1 +++ b/1 @@ -1,1 +1,1 @@ 1 EOF test_must_fail git apply --stat input && test_must_fail git apply --check input ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git apply should exit non-zero with unrecognized input.">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} {(SQ <"\n"> <"\ttest_commit 1\n">)}) (C {(test_expect_success)} {(SQ <"apply --check exits non-zero with unrecognized input">)} { (SQ <"\n"> <"\ttest_must_fail git apply --check - <<-\\EOF\n"> <"\tI am not a patch\n"> <"\tI look nothing like a patch\n"> <"\tgit apply must fail\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply exits non-zero with no-op patch">)} { (SQ <"\n"> <"\tcat >input <<-\\EOF &&\n"> <"\tdiff --get a/1 b/1\n"> <"\tindex 6696ea4..606eddd 100644\n"> <"\t--- a/1\n"> <"\t+++ b/1\n"> <"\t@@ -1,1 +1,1 @@\n"> <"\t 1\n"> <"\tEOF\n"> <"\ttest_must_fail git apply --stat input &&\n"> <"\ttest_must_fail git apply --check input\n"> ) } ) (C {(test_done)}) ] )