{"thread":{"id":"5572","subject":"git-apply fails to apply some patches","startedAt":"2006-09-15T13:22:25Z","lastAt":"2006-09-17T10:55:38Z","messageCount":8,"participants":["Gerrit Pape","Junio C Hamano","Jakub Narebski","Jonas Fonseca"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"26970","messageId":"20060915132225.12040.qmail@a0896f98af57b2.315fe32.mid.smarden.org","threadId":"5572","inReplyTo":null,"subject":"git-apply fails to apply some patches","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2006-09-15T13:22:25Z","receivedAt":"2006-09-15T13:22:25Z","isPatch":false,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"Hi, please see http://bugs.debian.org/386495 or below.  I can reproduce\nthe problem with 1.4.2.1.\n\nThanks, Gerrit.\n\n----- Forwarded message from Matthew Wilcox <matthew@wil.cx> -----\n\nTrying to apply a patch that was created with interdiff fails ...\nHere's the first patch (which works)\n\n--- pciutils-2.1.11.orig/debian/dirs\n+++ pciutils-2.1.11/debian/dirs\n@@ -0,0 +1,6 @@\n+usr/share/misc\n+usr/share/man\n+usr/bin\n+usr/lib\n+usr/share/lintian/overrides\n+bin\n\nOn top of that, I try to apply this interdiff generated patch:\n\ndiff -u pciutils-2.1.11/debian/dirs pciutils-2.1.11/debian/dirs\n--- pciutils-2.1.11/debian/dirs\n+++ pciutils-2.1.11/debian/dirs\n@@ -6,0 +7 @@\n+var/lib/pciutils\n\nand git-apply says:\n\nerror: debian/dirs: already exists in working directory\n\nI suspect it's confused by the '-x,0' thinking that means \"file does not\nexist\" rather than \"we have 0 context for this diff\".\n\n\n----- End forwarded message -----\n"},{"id":"27043","messageId":"7vzmcz6mrq.fsf@assigned-by-dhcp.cox.net","threadId":"5572","inReplyTo":"20060915132225.12040.qmail@a0896f98af57b2.315fe32.mid.smarden.org","subject":"Re: git-apply fails to apply some patches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T06:16:25Z","receivedAt":"2006-09-17T06:16:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gerrit Pape <pape@smarden.org> writes:\n\n>...\n> On top of that, I try to apply this interdiff generated patch:\n>\n> diff -u pciutils-2.1.11/debian/dirs pciutils-2.1.11/debian/dirs\n> --- pciutils-2.1.11/debian/dirs\n> +++ pciutils-2.1.11/debian/dirs\n> @@ -6,0 +7 @@\n> +var/lib/pciutils\n>\n> and git-apply says:\n>\n> error: debian/dirs: already exists in working directory\n>\n> I suspect it's confused by the '-x,0' thinking that means \"file does not\n> exist\" rather than \"we have 0 context for this diff\".\n\nThere are a few safety checks we perform assuming that the patch\nhas a few lines of context, and this is falsely triggering one\nof them.  It incorrectly thinks that seeing _no_ context nor old\nlines in the patch means this is a file creation patch, and\ncomplains because it knows the file being patched already\nexists.\n\nI am looking into a way to handle a context-less patch line the\none quoted, without breaking the sanity check we have.\n\nIn the meantime you should be able to work things around by not\nfeeding --unified=0 diff output.\n"},{"id":"27046","messageId":"7vsliq7vqr.fsf_-_@assigned-by-dhcp.cox.net","threadId":"5572","inReplyTo":"7vzmcz6mrq.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] apply --unidiff-zero: loosen sanity checks for --unidiff=0 patches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T08:17:16Z","receivedAt":"2006-09-17T08:17:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"One request and one question:\n\n (1) I think the attached patch should fix this.  Could you\n     see if it works for you?\n\n (2) Is it absolutely necessary to work with a context-free\n     patch in the workflow of the particular job (pciutils\n     maintenance)?  If so what is the reason?\n\n-- >8 --\nIn \"git-apply\", we have a few sanity checks and heuristics that\nexpects that the patch fed to us is a unified diff with at least\none line of context.\n\n * When there is no leading context line in a hunk, the hunk\n   must apply at the beginning of the preimage.  Similarly, no\n   trailing context means that the hunk is anchored at the end.\n\n * We learn a patch deletes the file from a hunk that has no\n   resulting line (i.e. all lines are prefixed with '-') if it\n   has not otherwise been known if the patch deletes the file.\n   Similarly, no old line means the file is being created.\n\nAnd we declare an error condition when the file created by a\ncreation patch already exists, and/or when a deletion patch\nstill leaves content in the file.\n\nThese sanity checks are good safety measures, but breaks down\nwhen people feed a diff generated with --unified=0.  This was\nrecently noticed first by Matthew Wilcox and Gerrit Pape.\n\nThis adds a new flag, --unified-zero, to allow bypassing these\nchecks.  If you are in control of the patch generation process,\nyou should not use --unified=0 patch and fix it up with this\nflag; rather you should try work with a patch with context.  But\nif all you have to work with is a patch without context, this\nflag may come handy as the last resort.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n builtin-apply.c           |  112 +++++++++++++++++++++++++++++++-------------\n t/t3403-rebase-skip.sh    |    4 +-\n t/t4104-apply-boundary.sh |  115 +++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 197 insertions(+), 34 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex 6e0864c..25e90d8 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -27,6 +27,7 @@ static const char *prefix;\n static int prefix_length = -1;\n static int newfd = -1;\n \n+static int unidiff_zero;\n static int p_value = 1;\n static int check_index;\n static int write_index;\n@@ -854,11 +855,10 @@ static int find_header(char *line, unsig\n }\n \n /*\n- * Parse a unified diff. Note that this really needs\n- * to parse each fragment separately, since the only\n- * way to know the difference between a \"---\" that is\n- * part of a patch, and a \"---\" that starts the next\n- * patch is to look at the line counts..\n+ * Parse a unified diff. Note that this really needs to parse each\n+ * fragment separately, since the only way to know the difference\n+ * between a \"---\" that is part of a patch, and a \"---\" that starts\n+ * the next patch is to look at the line counts..\n  */\n static int parse_fragment(char *line, unsigned long size, struct patch *patch, struct fragment *fragment)\n {\n@@ -875,31 +875,14 @@ static int parse_fragment(char *line, un\n \tleading = 0;\n \ttrailing = 0;\n \n-\tif (patch->is_new < 0) {\n-\t\tpatch->is_new =  !oldlines;\n-\t\tif (!oldlines)\n-\t\t\tpatch->old_name = NULL;\n-\t}\n-\tif (patch->is_delete < 0) {\n-\t\tpatch->is_delete = !newlines;\n-\t\tif (!newlines)\n-\t\t\tpatch->new_name = NULL;\n-\t}\n-\n-\tif (patch->is_new && oldlines)\n-\t\treturn error(\"new file depends on old contents\");\n-\tif (patch->is_delete != !newlines) {\n-\t\tif (newlines)\n-\t\t\treturn error(\"deleted file still has contents\");\n-\t\tfprintf(stderr, \"** warning: file %s becomes empty but is not deleted\\n\", patch->new_name);\n-\t}\n-\n \t/* Parse the thing.. */\n \tline += len;\n \tsize -= len;\n \tlinenr++;\n \tadded = deleted = 0;\n-\tfor (offset = len; size > 0; offset += len, size -= len, line += len, linenr++) {\n+\tfor (offset = len;\n+\t     0 < size;\n+\t     offset += len, size -= len, line += len, linenr++) {\n \t\tif (!oldlines && !newlines)\n \t\t\tbreak;\n \t\tlen = linelen(line, size);\n@@ -972,12 +955,18 @@ static int parse_fragment(char *line, un\n \n \tpatch->lines_added += added;\n \tpatch->lines_deleted += deleted;\n+\n+\tif (0 < patch->is_new && oldlines)\n+\t\treturn error(\"new file depends on old contents\");\n+\tif (0 < patch->is_delete && newlines)\n+\t\treturn error(\"deleted file still has contents\");\n \treturn offset;\n }\n \n static int parse_single_patch(char *line, unsigned long size, struct patch *patch)\n {\n \tunsigned long offset = 0;\n+\tunsigned long oldlines = 0, newlines = 0, context = 0;\n \tstruct fragment **fragp = &patch->fragments;\n \n \twhile (size > 4 && !memcmp(line, \"@@ -\", 4)) {\n@@ -988,9 +977,11 @@ static int parse_single_patch(char *line\n \t\tlen = parse_fragment(line, size, patch, fragment);\n \t\tif (len <= 0)\n \t\t\tdie(\"corrupt patch at line %d\", linenr);\n-\n \t\tfragment->patch = line;\n \t\tfragment->size = len;\n+\t\toldlines += fragment->oldlines;\n+\t\tnewlines += fragment->newlines;\n+\t\tcontext += fragment->leading + fragment->trailing;\n \n \t\t*fragp = fragment;\n \t\tfragp = &fragment->next;\n@@ -999,6 +990,46 @@ static int parse_single_patch(char *line\n \t\tline += len;\n \t\tsize -= len;\n \t}\n+\n+\t/*\n+\t * If something was removed (i.e. we have old-lines) it cannot\n+\t * be creation, and if something was added it cannot be\n+\t * deletion.  However, the reverse is not true; --unified=0\n+\t * patches that only add are not necessarily creation even\n+\t * though they do not have any old lines, and ones that only\n+\t * delete are not necessarily deletion.\n+\t *\n+\t * Unfortunately, a real creation/deletion patch do _not_ have\n+\t * any context line by definition, so we cannot safely tell it\n+\t * apart with --unified=0 insanity.  At least if the patch has\n+\t * more than one hunk it is not creation or deletion.\n+\t */\n+\tif (patch->is_new < 0 &&\n+\t    (oldlines || (patch->fragments && patch->fragments->next)))\n+\t\tpatch->is_new = 0;\n+\tif (patch->is_delete < 0 &&\n+\t    (newlines || (patch->fragments && patch->fragments->next)))\n+\t\tpatch->is_delete = 0;\n+\tif (!unidiff_zero || context) {\n+\t\t/* If the user says the patch is not generated with\n+\t\t * --unified=0, or if we have seen context lines,\n+\t\t * then not having oldlines means the patch is creation,\n+\t\t * and not having newlines means the patch is deletion.\n+\t\t */\n+\t\tif (patch->is_new < 0 && !oldlines)\n+\t\t\tpatch->is_new = 1;\n+\t\tif (patch->is_delete < 0 && !newlines)\n+\t\t\tpatch->is_delete = 1;\n+\t}\n+\n+\tif (0 < patch->is_new && oldlines)\n+\t\tdie(\"new file %s depends on old contents\", patch->new_name);\n+\tif (0 < patch->is_delete && newlines)\n+\t\tdie(\"deleted file %s still has contents\", patch->old_name);\n+\tif (!patch->is_delete && !newlines && context)\n+\t\tfprintf(stderr, \"** warning: file %s becomes empty but \"\n+\t\t\t\"is not deleted\\n\", patch->new_name);\n+\n \treturn offset;\n }\n \n@@ -1556,9 +1587,19 @@ static int apply_one_fragment(struct buf\n \t/*\n \t * If we don't have any leading/trailing data in the patch,\n \t * we want it to match at the beginning/end of the file.\n+\t *\n+\t * But that would break if the patch is generated with\n+\t * --unified=0; sane people wouldn't do that to cause us\n+\t * trouble, but we try to please not so sane ones as well.\n \t */\n-\tmatch_beginning = !leading && (frag->oldpos == 1);\n-\tmatch_end = !trailing;\n+\tif (unidiff_zero) {\n+\t\tmatch_beginning = (!leading && !frag->oldpos);\n+\t\tmatch_end = 0;\n+\t}\n+\telse {\n+\t\tmatch_beginning = !leading && (frag->oldpos == 1);\n+\t\tmatch_end = !trailing;\n+\t}\n \n \tlines = 0;\n \tpos = frag->newpos;\n@@ -1804,7 +1845,7 @@ static int apply_data(struct patch *patc\n \tpatch->result = desc.buffer;\n \tpatch->resultsize = desc.size;\n \n-\tif (patch->is_delete && patch->resultsize)\n+\tif (0 < patch->is_delete && patch->resultsize)\n \t\treturn error(\"removal patch leaves file contents\");\n \n \treturn 0;\n@@ -1876,7 +1917,7 @@ static int check_patch(struct patch *pat\n \t\t\t\told_name, st_mode, patch->old_mode);\n \t}\n \n-\tif (new_name && prev_patch && prev_patch->is_delete &&\n+\tif (new_name && prev_patch && 0 < prev_patch->is_delete &&\n \t    !strcmp(prev_patch->old_name, new_name))\n \t\t/* A type-change diff is always split into a patch to\n \t\t * delete old, immediately followed by a patch to\n@@ -1889,7 +1930,8 @@ static int check_patch(struct patch *pat\n \telse\n \t\tok_if_exists = 0;\n \n-\tif (new_name && (patch->is_new | patch->is_rename | patch->is_copy)) {\n+\tif (new_name &&\n+\t    ((0 < patch->is_new) | (0 < patch->is_rename) | patch->is_copy)) {\n \t\tif (check_index &&\n \t\t    cache_name_pos(new_name, strlen(new_name)) >= 0 &&\n \t\t    !ok_if_exists)\n@@ -1906,7 +1948,7 @@ static int check_patch(struct patch *pat\n \t\t\t\treturn error(\"%s: %s\", new_name, strerror(errno));\n \t\t}\n \t\tif (!patch->new_mode) {\n-\t\t\tif (patch->is_new)\n+\t\t\tif (0 < patch->is_new)\n \t\t\t\tpatch->new_mode = S_IFREG | 0644;\n \t\t\telse\n \t\t\t\tpatch->new_mode = patch->old_mode;\n@@ -1957,7 +1999,7 @@ static void show_index_list(struct patch\n \t\tconst char *name;\n \n \t\tname = patch->old_name ? patch->old_name : patch->new_name;\n-\t\tif (patch->is_new)\n+\t\tif (0 < patch->is_new)\n \t\t\tsha1_ptr = null_sha1;\n \t\telse if (get_sha1(patch->old_sha1_prefix, sha1))\n \t\t\tdie(\"sha1 information is lacking or useless (%s).\",\n@@ -2543,6 +2585,10 @@ int cmd_apply(int argc, const char **arg\n \t\t\tapply_in_reverse = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--unidiff-zero\")) {\n+\t\t\tunidiff_zero = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--reject\")) {\n \t\t\tapply = apply_with_reject = apply_verbosely = 1;\n \t\t\tcontinue;\ndiff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh\nindex 8ab63c5..bb25315 100755\n--- a/t/t3403-rebase-skip.sh\n+++ b/t/t3403-rebase-skip.sh\n@@ -37,7 +37,9 @@ test_expect_success setup '\n \tgit branch skip-merge skip-reference\n \t'\n \n-test_expect_failure 'rebase with git am -3 (default)' 'git rebase master'\n+test_expect_failure 'rebase with git am -3 (default)' '\n+\tgit rebase master\n+'\n \n test_expect_success 'rebase --skip with am -3' '\n \tgit reset --hard HEAD &&\ndiff --git a/t/t4104-apply-boundary.sh b/t/t4104-apply-boundary.sh\nnew file mode 100755\nindex 0000000..2ff800c\n--- /dev/null\n+++ b/t/t4104-apply-boundary.sh\n@@ -0,0 +1,115 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='git-apply boundary tests\n+\n+'\n+. ./test-lib.sh\n+\n+L=\"c d e f g h i j k l m n o p q r s t u v w x\"\n+\n+test_expect_success setup '\n+\tfor i in b '\"$L\"' y\n+\tdo\n+\t\techo $i\n+\tdone >victim &&\n+\tcat victim >original &&\n+\tgit update-index --add victim &&\n+\n+\t: add to the head\n+\tfor i in a b '\"$L\"' y\n+\tdo\n+\t\techo $i\n+\tdone >victim &&\n+\tcat victim >add-a-expect &&\n+\tgit diff victim >add-a-patch.with &&\n+\tgit diff --unified=0 >add-a-patch.without &&\n+\n+\t: modify at the head\n+\tfor i in a '\"$L\"' y\n+\tdo\n+\t\techo $i\n+\tdone >victim &&\n+\tcat victim >mod-a-expect &&\n+\tgit diff victim >mod-a-patch.with &&\n+\tgit diff --unified=0 >mod-a-patch.without &&\n+\n+\t: remove from the head\n+\tfor i in '\"$L\"' y\n+\tdo\n+\t\techo $i\n+\tdone >victim &&\n+\tcat victim >del-a-expect &&\n+\tgit diff victim >del-a-patch.with\n+\tgit diff --unified=0 >del-a-patch.without &&\n+\n+\t: add to the tail\n+\tfor i in b '\"$L\"' y z\n+\tdo\n+\t\techo $i\n+\tdone >victim &&\n+\tcat victim >add-z-expect &&\n+\tgit diff victim >add-z-patch.with &&\n+\tgit diff --unified=0 >add-z-patch.without &&\n+\n+\t: modify at the tail\n+\tfor i in a '\"$L\"' y\n+\tdo\n+\t\techo $i\n+\tdone >victim &&\n+\tcat victim >mod-z-expect &&\n+\tgit diff victim >mod-z-patch.with &&\n+\tgit diff --unified=0 >mod-z-patch.without &&\n+\n+\t: remove from the tail\n+\tfor i in b '\"$L\"'\n+\tdo\n+\t\techo $i\n+\tdone >victim &&\n+\tcat victim >del-z-expect &&\n+\tgit diff victim >del-z-patch.with\n+\tgit diff --unified=0 >del-z-patch.without &&\n+\n+\t: done\n+'\n+\n+for with in with without\n+do\n+\tcase \"$with\" in\n+\twith) u= ;;\n+\twithout) u='--unidiff-zero ' ;;\n+\tesac\n+\tfor kind in add-a add-z mod-a mod-z del-a del-z\n+\tdo\n+\t\ttest_expect_success \"apply $kind-patch $with context\" '\n+\t\t\tcat original >victim &&\n+\t\t\tgit update-index victim &&\n+\t\t\tgit apply --index '\"$u$kind-patch.$with\"' || {\n+\t\t\t\tcat '\"$kind-patch.$with\"'\n+\t\t\t\t(exit 1)\n+\t\t\t} &&\n+\t\t\tdiff -u '\"$kind\"'-expect victim\n+\t\t'\n+\tdone\n+done\n+\n+for kind in add-a add-z mod-a mod-z del-a del-z\n+do\n+\trm -f $kind-ng.without\n+\tsed\t-e \"s/^diff --git /diff /\" \\\n+\t\t-e '/^index /d' \\\n+\t\t<$kind-patch.without >$kind-ng.without\n+\ttest_expect_success \"apply non-git $kind-patch without context\" '\n+\t\tcat original >victim &&\n+\t\tgit update-index victim &&\n+\t\tgit apply --unidiff-zero --index '\"$kind-ng.without\"' || {\n+\t\t\tcat '\"$kind-ng.without\"'\n+\t\t\t(exit 1)\n+\t\t} &&\n+\t\tdiff -u '\"$kind\"'-expect victim\n+\t'\n+done\n+\n+test_done\n-- \n1.4.2.1.gca4e5c\n"},{"id":"27048","messageId":"eej12j$36t$2@sea.gmane.org","threadId":"5572","inReplyTo":"7vsliq7vqr.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] apply --unidiff-zero: loosen sanity checks for --unidiff=0 patches","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-17T08:30:52Z","receivedAt":"2006-09-17T08:30:52Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> This adds a new flag, --unified-zero, to allow bypassing these\n> checks.  If you are in control of the patch generation process,\n> you should not use --unified=0 patch and fix it up with this\n> flag; rather you should try work with a patch with context.  But\n> if all you have to work with is a patch without context, this\n> flag may come handy as the last resort.\n\nDoesn't -C0 option to git-apply bypass those checks?\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"27051","messageId":"7vac4y7u8n.fsf@assigned-by-dhcp.cox.net","threadId":"5572","inReplyTo":"eej12j$36t$2@sea.gmane.org","subject":"Re: [PATCH] apply --unidiff-zero: loosen sanity checks for --unidiff=0 patches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T08:49:44Z","receivedAt":"2006-09-17T08:49:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>\n>> This adds a new flag, --unified-zero, to allow bypassing these\n>> checks.  If you are in control of the patch generation process,\n>> you should not use --unified=0 patch and fix it up with this\n>> flag; rather you should try work with a patch with context.  But\n>> if all you have to work with is a patch without context, this\n>> flag may come handy as the last resort.\n>\n> Doesn't -C0 option to git-apply bypass those checks?\n\nOnly the head/tail anchor check, but not the creation/deletion\ncheck.\n\nAlso -CNUM's meaning is \"you are allowed to reduce context down\nto only this many lines if you need to (but you do not have to\nif you can find the right match with context recorded in the\npatch)\" not \"what I am feeding you is a context-free patch so\nloosen sanity checks\", so it does not make much sense to\noverload the flag with such a new meaning (if that is what you\nare implying, that is).\n"},{"id":"27055","messageId":"eej2s7$97c$2@sea.gmane.org","threadId":"5572","inReplyTo":"7vac4y7u8n.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] apply --unidiff-zero: loosen sanity checks for --unidiff=0 patches","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-17T09:01:36Z","receivedAt":"2006-09-17T09:01:36Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> Junio C Hamano wrote:\n>>\n>>> This adds a new flag, --unified-zero, to allow bypassing these\n>>> checks.  [...]\n>>\n>> Doesn't -C0 option to git-apply bypass those checks?\n> \n> Only the head/tail anchor check, but not the creation/deletion\n> check.\n\nAh. Well, --unified-zero (or --context-free) flag makes sense then.\n\nBy the way, could you document this option (usage and manpage), please?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"27060","messageId":"7v64fm6cuj.fsf@assigned-by-dhcp.cox.net","threadId":"5572","inReplyTo":"eej2s7$97c$2@sea.gmane.org","subject":"Re: [PATCH] apply --unidiff-zero: loosen sanity checks for --unidiff=0 patches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T09:50:44Z","receivedAt":"2006-09-17T09:50:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> By the way, could you document this option (usage and manpage), please?\n\nWill not do this late at night.  The list is welcome to come up\nwith a janotorial patch while I take a nap ;-).\n"},{"id":"27068","messageId":"20060917105538.GA1497@diku.dk","threadId":"5572","inReplyTo":"7v64fm6cuj.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] git-apply(1): document --unidiff-zero","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2006-09-17T10:55:38Z","receivedAt":"2006-09-17T10:55:38Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Signed-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n Documentation/git-apply.txt |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt\nindex c76cfff..ee136c1 100644\n--- a/Documentation/git-apply.txt\n+++ b/Documentation/git-apply.txt\n@@ -95,6 +95,16 @@ OPTIONS\n \tcontext exist they all must match.  By default no context is\n \tever ignored.\n \n+--unidiff-zero::\n+\tBy default, gitlink:git-apply[1] expects that the patch being\n+\tapplied is a unified diff with at least one line of context.\n+\tThis provides good safety measures, but breaks down when\n+\tapplying a diff generated with --unified=0. To bypass these\n+\tchecks use '--unidiff-zero'.\n++\n+Note, for the reasons stated above usage of context-free patches are\n+discouraged.\n+\n --apply::\n \tIf you use any of the options marked \"Turns off\n \t'apply'\" above, gitlink:git-apply[1] reads and outputs the\n-- \n1.4.2.g39f1\n\n-- \nJonas Fonseca\n"}]}