Re: [PATCH 2/2] apply: handle Subversion diffs with /dev/null gracefully

2018-02-15 Thread Junio C Hamano
Johannes Schindelin  writes:

>   } else {
> - if (!starts_with(line, "/dev/null\n"))
> + if (!is_dev_null(line))
>   return error(_("git apply: bad git-diff - expected 
> /dev/null on line %d"), state->linenr);
>   }

Yup.  This seems to be the last explicit/manual check with the
string "/dev/null" (instead of using is_dev_null(), which is how it
should be and already is done in codepaths that guesses -p value and
decides if it is a creation or a deletion patch).

Looks good.  Will queue.

> diff --git a/t/t4135-apply-weird-filenames.sh 
> b/t/t4135-apply-weird-filenames.sh
> index b14b8085786..c7c688fcc4b 100755
> --- a/t/t4135-apply-weird-filenames.sh
> +++ b/t/t4135-apply-weird-filenames.sh
> @@ -100,7 +100,7 @@ deleted file mode 100644
>  -
>  EOF
>  
> -test_expect_failure 'apply handles a diff generated by Subversion' '
> +test_expect_success 'apply handles a diff generated by Subversion' '
>   >Makefile &&
>   git apply -p2 diff-from-svn &&
>   test_path_is_missing Makefile


[PATCH 2/2] apply: handle Subversion diffs with /dev/null gracefully

2018-02-14 Thread Johannes Schindelin
From: Tatyana Krasnukha 

Subversion generates diffs that can contain lines like this one:

--- /dev/null  (nonexistent)

Let's teach Git's apply machinery to handle such a line gracefully.

This fixes https://github.com/git-for-windows/git/isues/1489

Signed-off-by: Tatyana Krasnukha 
Signed-off-by: Johannes Schindelin 
---
 apply.c  | 2 +-
 t/t4135-apply-weird-filenames.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/apply.c b/apply.c
index f8b67bfee2c..107aa4c216e 100644
--- a/apply.c
+++ b/apply.c
@@ -950,7 +950,7 @@ static int gitdiff_verify_name(struct apply_state *state,
}
free(another);
} else {
-   if (!starts_with(line, "/dev/null\n"))
+   if (!is_dev_null(line))
return error(_("git apply: bad git-diff - expected 
/dev/null on line %d"), state->linenr);
}
 
diff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh
index b14b8085786..c7c688fcc4b 100755
--- a/t/t4135-apply-weird-filenames.sh
+++ b/t/t4135-apply-weird-filenames.sh
@@ -100,7 +100,7 @@ deleted file mode 100644
 -
 EOF
 
-test_expect_failure 'apply handles a diff generated by Subversion' '
+test_expect_success 'apply handles a diff generated by Subversion' '
>Makefile &&
git apply -p2 diff-from-svn &&
test_path_is_missing Makefile
-- 
2.16.1.windows.1