{"thread":{"id":"47851","subject":"[PATCH 0/2] Teach `git apply` to accept Subversion-generated diffs","startedAt":"2018-02-15T00:29:38Z","lastAt":"2018-02-15T18:02:08Z","messageCount":4,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"339419","messageId":"cover.1518654532.git.johannes.schindelin@gmx.de","threadId":"47851","inReplyTo":null,"subject":"[PATCH 0/2] Teach `git apply` to accept Subversion-generated diffs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-02-15T00:29:23Z","receivedAt":"2018-02-15T00:29:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"They are accepted already, almost. With one exception: the ---/+++ lines\ncontain not only the file names, but continue with a TAB and then the\nrevision (or \"working copy\" or \"nonexistent\") in parenthesis.\n\nWe already handle these lines, except in the case of /dev/null. Let's handle\nthe case gracefully where the diff contains a \"--- /dev/null\" line with a\ntrailing comment.\n\nThis contribution came in via Pull Request to Git for Windows, from a first\ntime contributor! Yes!\n\n\nJohannes Schindelin (1):\n  apply: demonstrate a problem applying svn diffs\n\nTatyana Krasnukha (1):\n  apply: handle Subversion diffs with /dev/null gracefully\n\n apply.c                          |  2 +-\n t/t4135-apply-weird-filenames.sh | 17 +++++++++++++++++\n 2 files changed, 18 insertions(+), 1 deletion(-)\n\n\nbase-commit: b2e45c695d09f6a31ce09347ae0a5d2cdfe9dd4e\nPublished-As: https://github.com/dscho/git/releases/tag/apply-svn-diff-v1\nFetch-It-Via: git fetch https://github.com/dscho/git apply-svn-diff-v1\n-- \n2.16.1.windows.1\n\n"},{"id":"339420","messageId":"24000fd64887994bfc5b70b5e4bd3d8c92661f81.1518654532.git.johannes.schindelin@gmx.de","threadId":"47851","inReplyTo":"cover.1518654532.git.johannes.schindelin@gmx.de","subject":"[PATCH 1/2] apply: demonstrate a problem applying svn diffs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-02-15T00:29:27Z","receivedAt":"2018-02-15T00:29:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Subversion generates diffs that contain funny ---/+++ lines containing\nmore than just the file names. Example:\n\n\t--- a/trunk/README\t(revision 4711)\n\t+++ /dev/null\t(nonexistent)\n\nLet's add a test case demonstrating that apply cannot handle the\n/dev/null line (although it can handle the trunk/README line just fine).\n\nReported in https://github.com/git-for-windows/git/issues/1489\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t4135-apply-weird-filenames.sh | 17 +++++++++++++++++\n 1 file changed, 17 insertions(+)\n\ndiff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh\nindex 27cb0009fb1..b14b8085786 100755\n--- a/t/t4135-apply-weird-filenames.sh\n+++ b/t/t4135-apply-weird-filenames.sh\n@@ -89,4 +89,21 @@ test_expect_success 'traditional, whitespace-damaged, colon in timezone' '\n \ttest_cmp expected \"post image.txt\"\n '\n \n+cat >diff-from-svn <<\\EOF\n+Index: Makefile\n+===================================================================\n+diff --git a/branches/Makefile\n+deleted file mode 100644\n+--- a/branches/Makefile\t(revision 13)\n++++ /dev/null\t(nonexistent)\n+@@ +1 0,0 @@\n+-\n+EOF\n+\n+test_expect_failure 'apply handles a diff generated by Subversion' '\n+\t>Makefile &&\n+\tgit apply -p2 diff-from-svn &&\n+\ttest_path_is_missing Makefile\n+'\n+\n test_done\n-- \n2.16.1.windows.1\n\n\n"},{"id":"339421","messageId":"7858c01a2c92a55f86611335bbdcc93c94bc69d2.1518654532.git.johannes.schindelin@gmx.de","threadId":"47851","inReplyTo":"cover.1518654532.git.johannes.schindelin@gmx.de","subject":"[PATCH 2/2] apply: handle Subversion diffs with /dev/null gracefully","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-02-15T00:29:34Z","receivedAt":"2018-02-15T00:29:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Tatyana Krasnukha <tatyana@synopsys.com>\n\nSubversion generates diffs that can contain lines like this one:\n\n\t--- /dev/null  (nonexistent)\n\nLet's teach Git's apply machinery to handle such a line gracefully.\n\nThis fixes https://github.com/git-for-windows/git/isues/1489\n\nSigned-off-by: Tatyana Krasnukha <tatyana@synopsys.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n apply.c                          | 2 +-\n t/t4135-apply-weird-filenames.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex f8b67bfee2c..107aa4c216e 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -950,7 +950,7 @@ static int gitdiff_verify_name(struct apply_state *state,\n \t\t}\n \t\tfree(another);\n \t} else {\n-\t\tif (!starts_with(line, \"/dev/null\\n\"))\n+\t\tif (!is_dev_null(line))\n \t\t\treturn error(_(\"git apply: bad git-diff - expected /dev/null on line %d\"), state->linenr);\n \t}\n \ndiff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh\nindex b14b8085786..c7c688fcc4b 100755\n--- a/t/t4135-apply-weird-filenames.sh\n+++ b/t/t4135-apply-weird-filenames.sh\n@@ -100,7 +100,7 @@ deleted file mode 100644\n -\n EOF\n \n-test_expect_failure 'apply handles a diff generated by Subversion' '\n+test_expect_success 'apply handles a diff generated by Subversion' '\n \t>Makefile &&\n \tgit apply -p2 diff-from-svn &&\n \ttest_path_is_missing Makefile\n-- \n2.16.1.windows.1\n"},{"id":"339478","messageId":"xmqqsha29lnt.fsf@gitster-ct.c.googlers.com","threadId":"47851","inReplyTo":"7858c01a2c92a55f86611335bbdcc93c94bc69d2.1518654532.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH 2/2] apply: handle Subversion diffs with /dev/null gracefully","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-02-15T18:01:58Z","receivedAt":"2018-02-15T18:02:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n>  \t} else {\n> -\t\tif (!starts_with(line, \"/dev/null\\n\"))\n> +\t\tif (!is_dev_null(line))\n>  \t\t\treturn error(_(\"git apply: bad git-diff - expected /dev/null on line %d\"), state->linenr);\n>  \t}\n\nYup.  This seems to be the last explicit/manual check with the\nstring \"/dev/null\" (instead of using is_dev_null(), which is how it\nshould be and already is done in codepaths that guesses -p value and\ndecides if it is a creation or a deletion patch).\n\nLooks good.  Will queue.\n\n> diff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh\n> index b14b8085786..c7c688fcc4b 100755\n> --- a/t/t4135-apply-weird-filenames.sh\n> +++ b/t/t4135-apply-weird-filenames.sh\n> @@ -100,7 +100,7 @@ deleted file mode 100644\n>  -\n>  EOF\n>  \n> -test_expect_failure 'apply handles a diff generated by Subversion' '\n> +test_expect_success 'apply handles a diff generated by Subversion' '\n>  \t>Makefile &&\n>  \tgit apply -p2 diff-from-svn &&\n>  \ttest_path_is_missing Makefile\n"}]}