{"thread":{"id":"1990","subject":"Flag empty patches as errors","startedAt":"2005-10-01T06:25:23Z","lastAt":"2005-10-01T14:21:39Z","messageCount":4,"participants":["Linus Torvalds","Junio C Hamano","Martin Coxall","H. Peter Anvin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"9580","messageId":"Pine.LNX.4.64.0509302320560.3378@g5.osdl.org","threadId":"1990","inReplyTo":null,"subject":"Flag empty patches as errors","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-10-01T06:25:23Z","receivedAt":"2005-10-01T06:25:23Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nA patch that contains no actual diff, and that doesn't change any \nmeta-data is bad. It shouldn't be a patch at all, and git-apply shouldn't \njust accept it.\n\nThis caused a corrupted patch to be silently applied as an empty change in \nthe kernel, because the corruption ended up making the patch look empty.\n\nAn example of such a patch is one that contains the patch header, but \nwhere the initial fragment header (the \"@@ -nr,..\" line) is missing, \ncausing us to not parse any fragments.\n\nThe real \"patch\" program will also flag such patches as bad, with the \nmessage\n\n\tpatch: **** Only garbage was found in the patch input.\n\nand we should do likewise.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/apply.c b/apply.c\n--- a/apply.c\n+++ b/apply.c\n@@ -723,6 +723,16 @@ static int parse_single_patch(char *line\n \treturn offset;\n }\n \n+static inline int metadata_changes(struct patch *patch)\n+{\n+\treturn\tpatch->is_rename > 0 ||\n+\t\tpatch->is_copy > 0 ||\n+\t\tpatch->is_new > 0 ||\n+\t\tpatch->is_delete ||\n+\t\t(patch->old_mode && patch->new_mode &&\n+\t\t patch->old_mode != patch->new_mode);\n+}\n+\n static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)\n {\n \tint hdrsize, patchsize;\n@@ -733,6 +743,9 @@ static int parse_chunk(char *buffer, uns\n \n \tpatchsize = parse_single_patch(buffer + offset + hdrsize, size - offset - hdrsize, patch);\n \n+\tif (!patchsize && !metadata_changes(patch))\n+\t\tdie(\"patch with only garbage at line %d\", linenr);\n+\n \treturn offset + hdrsize + patchsize;\n }\n \n"},{"id":"9582","messageId":"7v3bnlaes7.fsf@assigned-by-dhcp.cox.net","threadId":"1990","inReplyTo":"Pine.LNX.4.64.0509302320560.3378@g5.osdl.org","subject":"Re: Flag empty patches as errors","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-01T07:15:52Z","receivedAt":"2005-10-01T07:15:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  Applied.\n"},{"id":"9587","messageId":"068ea79fc648433faa44a6d4cc287614@cream.org","threadId":"1990","inReplyTo":"Pine.LNX.4.64.0509302320560.3378@g5.osdl.org","subject":"Packing on kernel.org","fromName":"Martin Coxall","fromEmail":"quasi@cream.org","sentAt":"2005-10-01T09:02:38Z","receivedAt":"2005-10-01T09:02:38Z","isPatch":false,"sender":{"key":"quasi@cream.org","avatar":null},"body":"Was there an cron process or kernel.org that should be repacking the \npublic repositories periodically?\n\nThe git/cogito/sparse/linux-2.6 repositories all now have several \nthousand unpacked objects a piece, and it takes so long to do an http \nclone it's not even funny.\n\nMartin\n"},{"id":"9590","messageId":"433E9B73.3040807@zytor.com","threadId":"1990","inReplyTo":"068ea79fc648433faa44a6d4cc287614@cream.org","subject":"Re: Packing on kernel.org","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-10-01T14:21:39Z","receivedAt":"2005-10-01T14:21:39Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Martin Coxall wrote:\n> Was there an cron process or kernel.org that should be repacking the \n> public repositories periodically?\n\nNo, too many people complained.\n\n> The git/cogito/sparse/linux-2.6 repositories all now have several \n> thousand unpacked objects a piece, and it takes so long to do an http \n> clone it's not even funny.\n\nHARP: Please pack your repositories periodically.  PLEASE.  It matters \nespecially now when kernel.org is down one server.\n\nIf your username is high on this list, it's imperative that you pack \nyour trees:\n\nbrodo                 197469\nwim                   184343\nmarcelo                68442\njgarzik                59860\nlm                     39680\nmpm                    38995\npavel                  37624\nlenb                   36406\nhch                    34037\ndavem                  27671\njejb                   23553\nwilly                  21626\npasky                  17019\nsfrench                15912\nsmurf                  15236\nacme                   12504\ntorvalds                8834\naegl                    7369\nericvh                  6750\nroland                  6296\nairlied                 6053\nchrisw                  5619\naxboe                   5221\ndwmw2                   4101\ngregkh                  3659\ndtor                    3537\nhpa                     3350\npaulus                  2074\nperex                   1999\nbart                    1955\ncvaroqui                1537\nkay                     1250\njunio                   1119\nsam                     1073\nkkeil                   1050\n\n\t-hpa\n"}]}