builtin/apply: make parse_single_patch() return -1 on error
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_single_patch() should return a negative integer instead of calling die(). Let's do that by using error() and let's adjust the related test cases accordingly. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b654b34c1c
commit
dae197f753
@ -68,7 +68,7 @@ test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' '
|
||||
sed -e "s/-CIT/xCIT/" <output >broken &&
|
||||
test_must_fail git apply --stat --summary broken 2>detected &&
|
||||
detected=$(cat detected) &&
|
||||
detected=$(expr "$detected" : "fatal.*at line \\([0-9]*\\)\$") &&
|
||||
detected=$(expr "$detected" : "error.*at line \\([0-9]*\\)\$") &&
|
||||
detected=$(sed -ne "${detected}p" broken) &&
|
||||
test "$detected" = xCIT
|
||||
'
|
||||
@ -77,7 +77,7 @@ test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' '
|
||||
git diff --binary | sed -e "s/-CIT/xCIT/" >broken &&
|
||||
test_must_fail git apply --stat --summary broken 2>detected &&
|
||||
detected=$(cat detected) &&
|
||||
detected=$(expr "$detected" : "fatal.*at line \\([0-9]*\\)\$") &&
|
||||
detected=$(expr "$detected" : "error.*at line \\([0-9]*\\)\$") &&
|
||||
detected=$(sed -ne "${detected}p" broken) &&
|
||||
test "$detected" = xCIT
|
||||
'
|
||||
|
Reference in New Issue
Block a user