{"thread":{"id":"45904","subject":"[PATCH] diff.c: Fix whitespace issues due to a mismerge(?)","startedAt":"2017-05-08T18:44:06Z","lastAt":"2017-05-09T02:38:13Z","messageCount":3,"participants":["Stefan Beller","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"319108","messageId":"20170508184354.31671-1-sbeller@google.com","threadId":"45904","inReplyTo":null,"subject":"[PATCH] diff.c: Fix whitespace issues due to a mismerge(?)","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-08T18:43:54Z","receivedAt":"2017-05-08T18:44:06Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Re-indent lines, as they were off by one.\nWhen a line was not indented (as you would expect from function defintions)\nwe had a stray whitespace preceding the line.\nIndented lines have a stray white space after the indentation by tabs,\nbefore the actual text, i.e.\n\n<TAB><WS>if (...)\n<TAB><TAB><WS>...\n\nIt looks like all these lines were introduced by one of the conflict chunks\nin 4af9a7d344 (Merge branch 'bc/object-id', 2016-09-19). Viewing that\ncommit in gitk, the indentation seems fine, i.e. there is just one\nwhitespace in front of the lines, as you would expect from a formatted\npatch.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n Junio, \n I do not think it is worth to apply this patch on its own,\n but maybe it is worth to investigate your setup? (Assuming it is\n git that did the merge, we may have a bug in whitespacing and\n merge conflicts.)\n \n Thanks,\n Stefan\n\n apply.c | 310 ++++++++++++++++++++++++++++++++--------------------------------\n 1 file changed, 155 insertions(+), 155 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex e6dbab26ad..be340991d7 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4098,172 +4098,172 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)\n \t return 0;\n  }\n \n- static void stat_patch_list(struct apply_state *state, struct patch *patch)\n- {\n-\t int files, adds, dels;\n-\n-\t for (files = adds = dels = 0 ; patch ; patch = patch->next) {\n-\t\t files++;\n-\t\t adds += patch->lines_added;\n-\t\t dels += patch->lines_deleted;\n-\t\t show_stats(state, patch);\n-\t }\n-\n-\t print_stat_summary(stdout, files, adds, dels);\n- }\n+static void stat_patch_list(struct apply_state *state, struct patch *patch)\n+{\n+\tint files, adds, dels;\n \n- static void numstat_patch_list(struct apply_state *state,\n+\tfor (files = adds = dels = 0 ; patch ; patch = patch->next) {\n+\t\tfiles++;\n+\t\tadds += patch->lines_added;\n+\t\tdels += patch->lines_deleted;\n+\t\tshow_stats(state, patch);\n+\t}\n+\n+\tprint_stat_summary(stdout, files, adds, dels);\n+}\n+\n+static void numstat_patch_list(struct apply_state *state,\n \t\t\t\tstruct patch *patch)\n- {\n-\t for ( ; patch; patch = patch->next) {\n-\t\t const char *name;\n-\t\t name = patch->new_name ? patch->new_name : patch->old_name;\n-\t\t if (patch->is_binary)\n-\t\t\t printf(\"-\\t-\\t\");\n-\t\t else\n-\t\t\t printf(\"%d\\t%d\\t\", patch->lines_added, patch->lines_deleted);\n-\t\t write_name_quoted(name, stdout, state->line_termination);\n-\t }\n- }\n+{\n+\tfor ( ; patch; patch = patch->next) {\n+\t\tconst char *name;\n+\t\tname = patch->new_name ? patch->new_name : patch->old_name;\n+\t\tif (patch->is_binary)\n+\t\t\tprintf(\"-\\t-\\t\");\n+\t\telse\n+\t\t\tprintf(\"%d\\t%d\\t\", patch->lines_added, patch->lines_deleted);\n+\t\twrite_name_quoted(name, stdout, state->line_termination);\n+\t}\n+}\n \n- static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)\n- {\n-\t if (mode)\n-\t\t printf(\" %s mode %06o %s\\n\", newdelete, mode, name);\n+static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)\n+{\n+\tif (mode)\n+\t\tprintf(\" %s mode %06o %s\\n\", newdelete, mode, name);\n \t else\n-\t\t printf(\" %s %s\\n\", newdelete, name);\n- }\n+\t\tprintf(\" %s %s\\n\", newdelete, name);\n+}\n \n- static void show_mode_change(struct patch *p, int show_name)\n- {\n-\t if (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {\n-\t\t if (show_name)\n-\t\t\t printf(\" mode change %06o => %06o %s\\n\",\n+static void show_mode_change(struct patch *p, int show_name)\n+{\n+\tif (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {\n+\t\tif (show_name)\n+\t\t\tprintf(\" mode change %06o => %06o %s\\n\",\n \t\t\t\tp->old_mode, p->new_mode, p->new_name);\n-\t\t else\n-\t\t\t printf(\" mode change %06o => %06o\\n\",\n-\t\t\t\tp->old_mode, p->new_mode);\n-\t }\n- }\n+\t\telse\n+\t\t\tprintf(\" mode change %06o => %06o\\n\",\n+\t\t\t       p->old_mode, p->new_mode);\n+\t}\n+}\n \n- static void show_rename_copy(struct patch *p)\n- {\n-\t const char *renamecopy = p->is_rename ? \"rename\" : \"copy\";\n-\t const char *old, *new;\n-\n-\t /* Find common prefix */\n-\t old = p->old_name;\n-\t new = p->new_name;\n-\t while (1) {\n-\t\t const char *slash_old, *slash_new;\n-\t\t slash_old = strchr(old, '/');\n-\t\t slash_new = strchr(new, '/');\n-\t\t if (!slash_old ||\n-\t\t     !slash_new ||\n-\t\t     slash_old - old != slash_new - new ||\n-\t\t     memcmp(old, new, slash_new - new))\n-\t\t\t break;\n-\t\t old = slash_old + 1;\n-\t\t new = slash_new + 1;\n-\t }\n-\t /* p->old_name thru old is the common prefix, and old and new\n-\t  * through the end of names are renames\n-\t  */\n-\t if (old != p->old_name)\n-\t\t printf(\" %s %.*s{%s => %s} (%d%%)\\n\", renamecopy,\n-\t\t\t(int)(old - p->old_name), p->old_name,\n-\t\t\told, new, p->score);\n-\t else\n-\t\t printf(\" %s %s => %s (%d%%)\\n\", renamecopy,\n-\t\t\tp->old_name, p->new_name, p->score);\n-\t show_mode_change(p, 0);\n- }\n+static void show_rename_copy(struct patch *p)\n+{\n+\tconst char *renamecopy = p->is_rename ? \"rename\" : \"copy\";\n+\tconst char *old, *new;\n \n- static void summary_patch_list(struct patch *patch)\n- {\n-\t struct patch *p;\n-\n-\t for (p = patch; p; p = p->next) {\n-\t\t if (p->is_new)\n-\t\t\t show_file_mode_name(\"create\", p->new_mode, p->new_name);\n-\t\t else if (p->is_delete)\n-\t\t\t show_file_mode_name(\"delete\", p->old_mode, p->old_name);\n-\t\t else {\n-\t\t\t if (p->is_rename || p->is_copy)\n-\t\t\t\t show_rename_copy(p);\n-\t\t\t else {\n-\t\t\t\t if (p->score) {\n-\t\t\t\t\t printf(\" rewrite %s (%d%%)\\n\",\n-\t\t\t\t\t\tp->new_name, p->score);\n-\t\t\t\t\t show_mode_change(p, 0);\n-\t\t\t\t }\n-\t\t\t\t else\n-\t\t\t\t\t show_mode_change(p, 1);\n-\t\t\t }\n-\t\t }\n-\t }\n- }\n+\t/* Find common prefix */\n+\told = p->old_name;\n+\tnew = p->new_name;\n+\twhile (1) {\n+\t\tconst char *slash_old, *slash_new;\n+\t\tslash_old = strchr(old, '/');\n+\t\tslash_new = strchr(new, '/');\n+\t\tif (!slash_old ||\n+\t\t    !slash_new ||\n+\t\t    slash_old - old != slash_new - new ||\n+\t\t    memcmp(old, new, slash_new - new))\n+\t\t\tbreak;\n+\t\told = slash_old + 1;\n+\t\tnew = slash_new + 1;\n+\t}\n+\t/* p->old_name thru old is the common prefix, and old and new\n+\t * through the end of names are renames\n+\t */\n+\tif (old != p->old_name)\n+\t\tprintf(\" %s %.*s{%s => %s} (%d%%)\\n\", renamecopy,\n+\t\t       (int)(old - p->old_name), p->old_name,\n+\t\t       old, new, p->score);\n+\telse\n+\t\tprintf(\" %s %s => %s (%d%%)\\n\", renamecopy,\n+\t\t       p->old_name, p->new_name, p->score);\n+\tshow_mode_change(p, 0);\n+}\n \n- static void patch_stats(struct apply_state *state, struct patch *patch)\n- {\n-\t int lines = patch->lines_added + patch->lines_deleted;\n-\n-\t if (lines > state->max_change)\n-\t\t state->max_change = lines;\n-\t if (patch->old_name) {\n-\t\t int len = quote_c_style(patch->old_name, NULL, NULL, 0);\n-\t\t if (!len)\n-\t\t\t len = strlen(patch->old_name);\n-\t\t if (len > state->max_len)\n-\t\t\t state->max_len = len;\n-\t }\n-\t if (patch->new_name) {\n-\t\t int len = quote_c_style(patch->new_name, NULL, NULL, 0);\n-\t\t if (!len)\n-\t\t\t len = strlen(patch->new_name);\n-\t\t if (len > state->max_len)\n-\t\t\t state->max_len = len;\n-\t }\n- }\n+static void summary_patch_list(struct patch *patch)\n+{\n+\tstruct patch *p;\n \n- static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)\n- {\n-\t if (state->update_index) {\n-\t\t if (remove_file_from_cache(patch->old_name) < 0)\n-\t\t\t return error(_(\"unable to remove %s from index\"), patch->old_name);\n-\t }\n-\t if (!state->cached) {\n-\t\t if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {\n-\t\t\t remove_path(patch->old_name);\n-\t\t }\n-\t }\n-\t return 0;\n- }\n+\tfor (p = patch; p; p = p->next) {\n+\t\tif (p->is_new)\n+\t\t\tshow_file_mode_name(\"create\", p->new_mode, p->new_name);\n+\t\telse if (p->is_delete)\n+\t\t\tshow_file_mode_name(\"delete\", p->old_mode, p->old_name);\n+\t\telse {\n+\t\t\tif (p->is_rename || p->is_copy)\n+\t\t\t\tshow_rename_copy(p);\n+\t\t\telse {\n+\t\t\t\tif (p->score) {\n+\t\t\t\t\tprintf(\" rewrite %s (%d%%)\\n\",\n+\t\t\t\t\t       p->new_name, p->score);\n+\t\t\t\t\tshow_mode_change(p, 0);\n+\t\t\t\t}\n+\t\t\t\telse\n+\t\t\t\t\tshow_mode_change(p, 1);\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n \n- static int add_index_file(struct apply_state *state,\n-\t\t\t   const char *path,\n-\t\t\t   unsigned mode,\n-\t\t\t   void *buf,\n-\t\t\t   unsigned long size)\n- {\n-\t struct stat st;\n-\t struct cache_entry *ce;\n-\t int namelen = strlen(path);\n-\t unsigned ce_size = cache_entry_size(namelen);\n-\n-\t if (!state->update_index)\n-\t\t return 0;\n-\n-\t ce = xcalloc(1, ce_size);\n-\t memcpy(ce->name, path, namelen);\n-\t ce->ce_mode = create_ce_mode(mode);\n-\t ce->ce_flags = create_ce_flags(0);\n-\t ce->ce_namelen = namelen;\n-\t if (S_ISGITLINK(mode)) {\n-\t\t const char *s;\n-\n-\t\t if (!skip_prefix(buf, \"Subproject commit \", &s) ||\n-\t\t     get_oid_hex(s, &ce->oid)) {\n+static void patch_stats(struct apply_state *state, struct patch *patch)\n+{\n+\tint lines = patch->lines_added + patch->lines_deleted;\n+\n+\tif (lines > state->max_change)\n+\t\tstate->max_change = lines;\n+\tif (patch->old_name) {\n+\t\tint len = quote_c_style(patch->old_name, NULL, NULL, 0);\n+\t\tif (!len)\n+\t\t\tlen = strlen(patch->old_name);\n+\t\tif (len > state->max_len)\n+\t\t\tstate->max_len = len;\n+\t}\n+\tif (patch->new_name) {\n+\t\tint len = quote_c_style(patch->new_name, NULL, NULL, 0);\n+\t\tif (!len)\n+\t\t\tlen = strlen(patch->new_name);\n+\t\tif (len > state->max_len)\n+\t\t\tstate->max_len = len;\n+\t}\n+}\n+\n+static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)\n+{\n+\tif (state->update_index) {\n+\t\tif (remove_file_from_cache(patch->old_name) < 0)\n+\t\t\treturn error(_(\"unable to remove %s from index\"), patch->old_name);\n+\t}\n+\tif (!state->cached) {\n+\t\tif (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {\n+\t\t\tremove_path(patch->old_name);\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static int add_index_file(struct apply_state *state,\n+\t\t\t  const char *path,\n+\t\t\t  unsigned mode,\n+\t\t\t  void *buf,\n+\t\t\t  unsigned long size)\n+{\n+\tstruct stat st;\n+\tstruct cache_entry *ce;\n+\tint namelen = strlen(path);\n+\tunsigned ce_size = cache_entry_size(namelen);\n+\n+\tif (!state->update_index)\n+\t\treturn 0;\n+\n+\tce = xcalloc(1, ce_size);\n+\tmemcpy(ce->name, path, namelen);\n+\tce->ce_mode = create_ce_mode(mode);\n+\tce->ce_flags = create_ce_flags(0);\n+\tce->ce_namelen = namelen;\n+\tif (S_ISGITLINK(mode)) {\n+\t\tconst char *s;\n+\n+\t\tif (!skip_prefix(buf, \"Subproject commit \", &s) ||\n+\t\t    get_oid_hex(s, &ce->oid)) {\n \t\t\tfree(ce);\n \t\t\treturn error(_(\"corrupt patch for submodule %s\"), path);\n \t\t}\n-- \n2.13.0.rc2.17.g46b64dc68a\n\n"},{"id":"319137","messageId":"xmqqo9v26ax1.fsf@gitster.mtv.corp.google.com","threadId":"45904","inReplyTo":"20170508184354.31671-1-sbeller@google.com","subject":"Re: [PATCH] diff.c: Fix whitespace issues due to a mismerge(?)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-09T02:06:50Z","receivedAt":"2017-05-09T02:06:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> It looks like all these lines were introduced by one of the conflict chunks\n> in 4af9a7d344 (Merge branch 'bc/object-id', 2016-09-19). Viewing that\n> commit in gitk, the indentation seems fine, i.e. there is just one\n> whitespace in front of the lines, as you would expect from a formatted\n> patch.\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>\n>  Junio, \n>  I do not think it is worth to apply this patch on its own,\n>  but maybe it is worth to investigate your setup? (Assuming it is\n>  git that did the merge, we may have a bug in whitespacing and\n>  merge conflicts.)\n\nThanks for spotting.  \n\nI do not think you have to worry about any bug in Git-the-program\nwith this merge.  If you try to reproduce the merge yourself (which\nby the way is easy to do, with \"M=4af9a7d344 && git checkout $M^ &&\ngit merge $M^2\"), you'll see that quite a lot of changes made to\n\"builtin/apply.c\" had to be hand-ported to the corresponding lines\nthat are now in \"apply.c\" at the top-level, because in the meantime\n13b5af22 (\"apply: move libified code from builtin/apply.c to\napply.{c,h}\", 2016-04-22) moved things around while the merged side\nbranch has been cooking.  \n\nIt is very likely that manual killing and yanking in Emacs\nintroduced the screw-up.\n"},{"id":"319144","messageId":"xmqq8tm669h0.fsf@gitster.mtv.corp.google.com","threadId":"45904","inReplyTo":"xmqqo9v26ax1.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] diff.c: Fix whitespace issues due to a mismerge(?)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-09T02:38:03Z","receivedAt":"2017-05-09T02:38:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Thanks for spotting.  \n>\n> I do not think you have to worry about any bug in Git-the-program\n> with this merge.  If you try to reproduce the merge yourself (which\n> by the way is easy to do, with \"M=4af9a7d344 && git checkout $M^ &&\n> git merge $M^2\"), you'll see that quite a lot of changes made to\n> \"builtin/apply.c\" had to be hand-ported to the corresponding lines\n> that are now in \"apply.c\" at the top-level, because in the meantime\n> 13b5af22 (\"apply: move libified code from builtin/apply.c to\n> apply.{c,h}\", 2016-04-22) moved things around while the merged side\n> branch has been cooking.  \n>\n> It is very likely that manual killing and yanking in Emacs\n> introduced the screw-up.\n\nI did your patch manually by hand and saw that a few hunks are still\nleft whitespace-broken by your patch, so I committed this one\ninstead.  Thanks.\n\n-- >8 --\nFrom: Junio C Hamano <gitster@pobox.com>\nDate: Mon, 8 May 2017 19:30:24 -0700\nSubject: [PATCH] apply.c: fix whitespace-only mismerge\n\n4af9a7d3 (\"Merge branch 'bc/object-id'\", 2016-09-19) involved\nmerging a lot of changes made to builtin/apply.c on the side branch\nmanually to apply.c as an intervening commit 13b5af22 (\"apply: move\nlibified code from builtin/apply.c to apply.{c,h}\", 2016-04-22)\nmoved a lot of the lines changed on the side branch to a different\nfile apply.c at the top-level, requiring manual patching of it.\nApparently, the maintainer screwed up and made the code indent in a\nfunny way while doing so.\n\nReported-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n apply.c | 338 ++++++++++++++++++++++++++++++++--------------------------------\n 1 file changed, 169 insertions(+), 169 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 0e2caeab9c..acebd1cb49 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4091,181 +4091,181 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)\n \tres = write_locked_index(&result, &lock, COMMIT_LOCK);\n \tdiscard_index(&result);\n \n-\t if (res)\n-\t\t return error(_(\"could not write temporary index to %s\"),\n-\t\t\t      state->fake_ancestor);\n+\tif (res)\n+\t\treturn error(_(\"could not write temporary index to %s\"),\n+\t\t\t     state->fake_ancestor);\n \n-\t return 0;\n- }\n+\treturn 0;\n+}\n \n- static void stat_patch_list(struct apply_state *state, struct patch *patch)\n- {\n-\t int files, adds, dels;\n+static void stat_patch_list(struct apply_state *state, struct patch *patch)\n+{\n+\tint files, adds, dels;\n \n-\t for (files = adds = dels = 0 ; patch ; patch = patch->next) {\n-\t\t files++;\n-\t\t adds += patch->lines_added;\n-\t\t dels += patch->lines_deleted;\n-\t\t show_stats(state, patch);\n-\t }\n+\tfor (files = adds = dels = 0 ; patch ; patch = patch->next) {\n+\t\tfiles++;\n+\t\tadds += patch->lines_added;\n+\t\tdels += patch->lines_deleted;\n+\t\tshow_stats(state, patch);\n+\t}\n \n-\t print_stat_summary(stdout, files, adds, dels);\n- }\n+\tprint_stat_summary(stdout, files, adds, dels);\n+}\n \n- static void numstat_patch_list(struct apply_state *state,\n-\t\t\t\tstruct patch *patch)\n- {\n-\t for ( ; patch; patch = patch->next) {\n-\t\t const char *name;\n-\t\t name = patch->new_name ? patch->new_name : patch->old_name;\n-\t\t if (patch->is_binary)\n-\t\t\t printf(\"-\\t-\\t\");\n-\t\t else\n-\t\t\t printf(\"%d\\t%d\\t\", patch->lines_added, patch->lines_deleted);\n-\t\t write_name_quoted(name, stdout, state->line_termination);\n-\t }\n- }\n-\n- static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)\n- {\n-\t if (mode)\n-\t\t printf(\" %s mode %06o %s\\n\", newdelete, mode, name);\n-\t else\n-\t\t printf(\" %s %s\\n\", newdelete, name);\n- }\n-\n- static void show_mode_change(struct patch *p, int show_name)\n- {\n-\t if (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {\n-\t\t if (show_name)\n-\t\t\t printf(\" mode change %06o => %06o %s\\n\",\n-\t\t\t\tp->old_mode, p->new_mode, p->new_name);\n-\t\t else\n-\t\t\t printf(\" mode change %06o => %06o\\n\",\n-\t\t\t\tp->old_mode, p->new_mode);\n-\t }\n- }\n-\n- static void show_rename_copy(struct patch *p)\n- {\n-\t const char *renamecopy = p->is_rename ? \"rename\" : \"copy\";\n-\t const char *old, *new;\n-\n-\t /* Find common prefix */\n-\t old = p->old_name;\n-\t new = p->new_name;\n-\t while (1) {\n-\t\t const char *slash_old, *slash_new;\n-\t\t slash_old = strchr(old, '/');\n-\t\t slash_new = strchr(new, '/');\n-\t\t if (!slash_old ||\n-\t\t     !slash_new ||\n-\t\t     slash_old - old != slash_new - new ||\n-\t\t     memcmp(old, new, slash_new - new))\n-\t\t\t break;\n-\t\t old = slash_old + 1;\n-\t\t new = slash_new + 1;\n-\t }\n-\t /* p->old_name thru old is the common prefix, and old and new\n-\t  * through the end of names are renames\n-\t  */\n-\t if (old != p->old_name)\n-\t\t printf(\" %s %.*s{%s => %s} (%d%%)\\n\", renamecopy,\n-\t\t\t(int)(old - p->old_name), p->old_name,\n-\t\t\told, new, p->score);\n-\t else\n-\t\t printf(\" %s %s => %s (%d%%)\\n\", renamecopy,\n-\t\t\tp->old_name, p->new_name, p->score);\n-\t show_mode_change(p, 0);\n- }\n-\n- static void summary_patch_list(struct patch *patch)\n- {\n-\t struct patch *p;\n-\n-\t for (p = patch; p; p = p->next) {\n-\t\t if (p->is_new)\n-\t\t\t show_file_mode_name(\"create\", p->new_mode, p->new_name);\n-\t\t else if (p->is_delete)\n-\t\t\t show_file_mode_name(\"delete\", p->old_mode, p->old_name);\n-\t\t else {\n-\t\t\t if (p->is_rename || p->is_copy)\n-\t\t\t\t show_rename_copy(p);\n-\t\t\t else {\n-\t\t\t\t if (p->score) {\n-\t\t\t\t\t printf(\" rewrite %s (%d%%)\\n\",\n-\t\t\t\t\t\tp->new_name, p->score);\n-\t\t\t\t\t show_mode_change(p, 0);\n-\t\t\t\t }\n-\t\t\t\t else\n-\t\t\t\t\t show_mode_change(p, 1);\n-\t\t\t }\n-\t\t }\n-\t }\n- }\n-\n- static void patch_stats(struct apply_state *state, struct patch *patch)\n- {\n-\t int lines = patch->lines_added + patch->lines_deleted;\n-\n-\t if (lines > state->max_change)\n-\t\t state->max_change = lines;\n-\t if (patch->old_name) {\n-\t\t int len = quote_c_style(patch->old_name, NULL, NULL, 0);\n-\t\t if (!len)\n-\t\t\t len = strlen(patch->old_name);\n-\t\t if (len > state->max_len)\n-\t\t\t state->max_len = len;\n-\t }\n-\t if (patch->new_name) {\n-\t\t int len = quote_c_style(patch->new_name, NULL, NULL, 0);\n-\t\t if (!len)\n-\t\t\t len = strlen(patch->new_name);\n-\t\t if (len > state->max_len)\n-\t\t\t state->max_len = len;\n-\t }\n- }\n-\n- static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)\n- {\n-\t if (state->update_index) {\n-\t\t if (remove_file_from_cache(patch->old_name) < 0)\n-\t\t\t return error(_(\"unable to remove %s from index\"), patch->old_name);\n-\t }\n-\t if (!state->cached) {\n-\t\t if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {\n-\t\t\t remove_path(patch->old_name);\n-\t\t }\n-\t }\n-\t return 0;\n- }\n-\n- static int add_index_file(struct apply_state *state,\n-\t\t\t   const char *path,\n-\t\t\t   unsigned mode,\n-\t\t\t   void *buf,\n-\t\t\t   unsigned long size)\n- {\n-\t struct stat st;\n-\t struct cache_entry *ce;\n-\t int namelen = strlen(path);\n-\t unsigned ce_size = cache_entry_size(namelen);\n-\n-\t if (!state->update_index)\n-\t\t return 0;\n-\n-\t ce = xcalloc(1, ce_size);\n-\t memcpy(ce->name, path, namelen);\n-\t ce->ce_mode = create_ce_mode(mode);\n-\t ce->ce_flags = create_ce_flags(0);\n-\t ce->ce_namelen = namelen;\n-\t if (S_ISGITLINK(mode)) {\n-\t\t const char *s;\n-\n-\t\t if (!skip_prefix(buf, \"Subproject commit \", &s) ||\n-\t\t     get_oid_hex(s, &ce->oid)) {\n+static void numstat_patch_list(struct apply_state *state,\n+\t\t\t       struct patch *patch)\n+{\n+\tfor ( ; patch; patch = patch->next) {\n+\t\tconst char *name;\n+\t\tname = patch->new_name ? patch->new_name : patch->old_name;\n+\t\tif (patch->is_binary)\n+\t\t\tprintf(\"-\\t-\\t\");\n+\t\telse\n+\t\t\tprintf(\"%d\\t%d\\t\", patch->lines_added, patch->lines_deleted);\n+\t\twrite_name_quoted(name, stdout, state->line_termination);\n+\t}\n+}\n+\n+static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)\n+{\n+\tif (mode)\n+\t\tprintf(\" %s mode %06o %s\\n\", newdelete, mode, name);\n+\telse\n+\t\tprintf(\" %s %s\\n\", newdelete, name);\n+}\n+\n+static void show_mode_change(struct patch *p, int show_name)\n+{\n+\tif (p->old_mode && p->new_mode && p->old_mode != p->new_mode) {\n+\t\tif (show_name)\n+\t\t\tprintf(\" mode change %06o => %06o %s\\n\",\n+\t\t\t       p->old_mode, p->new_mode, p->new_name);\n+\t\telse\n+\t\t\tprintf(\" mode change %06o => %06o\\n\",\n+\t\t\t       p->old_mode, p->new_mode);\n+\t}\n+}\n+\n+static void show_rename_copy(struct patch *p)\n+{\n+\tconst char *renamecopy = p->is_rename ? \"rename\" : \"copy\";\n+\tconst char *old, *new;\n+\n+\t/* Find common prefix */\n+\told = p->old_name;\n+\tnew = p->new_name;\n+\twhile (1) {\n+\t\tconst char *slash_old, *slash_new;\n+\t\tslash_old = strchr(old, '/');\n+\t\tslash_new = strchr(new, '/');\n+\t\tif (!slash_old ||\n+\t\t    !slash_new ||\n+\t\t    slash_old - old != slash_new - new ||\n+\t\t    memcmp(old, new, slash_new - new))\n+\t\t\tbreak;\n+\t\told = slash_old + 1;\n+\t\tnew = slash_new + 1;\n+\t}\n+\t/* p->old_name thru old is the common prefix, and old and new\n+\t * through the end of names are renames\n+\t */\n+\tif (old != p->old_name)\n+\t\tprintf(\" %s %.*s{%s => %s} (%d%%)\\n\", renamecopy,\n+\t\t       (int)(old - p->old_name), p->old_name,\n+\t\t       old, new, p->score);\n+\telse\n+\t\tprintf(\" %s %s => %s (%d%%)\\n\", renamecopy,\n+\t\t       p->old_name, p->new_name, p->score);\n+\tshow_mode_change(p, 0);\n+}\n+\n+static void summary_patch_list(struct patch *patch)\n+{\n+\tstruct patch *p;\n+\n+\tfor (p = patch; p; p = p->next) {\n+\t\tif (p->is_new)\n+\t\t\tshow_file_mode_name(\"create\", p->new_mode, p->new_name);\n+\t\telse if (p->is_delete)\n+\t\t\tshow_file_mode_name(\"delete\", p->old_mode, p->old_name);\n+\t\telse {\n+\t\t\tif (p->is_rename || p->is_copy)\n+\t\t\t\tshow_rename_copy(p);\n+\t\t\telse {\n+\t\t\t\tif (p->score) {\n+\t\t\t\t\tprintf(\" rewrite %s (%d%%)\\n\",\n+\t\t\t\t\t       p->new_name, p->score);\n+\t\t\t\t\tshow_mode_change(p, 0);\n+\t\t\t\t}\n+\t\t\t\telse\n+\t\t\t\t\tshow_mode_change(p, 1);\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+static void patch_stats(struct apply_state *state, struct patch *patch)\n+{\n+\tint lines = patch->lines_added + patch->lines_deleted;\n+\n+\tif (lines > state->max_change)\n+\t\tstate->max_change = lines;\n+\tif (patch->old_name) {\n+\t\tint len = quote_c_style(patch->old_name, NULL, NULL, 0);\n+\t\tif (!len)\n+\t\t\tlen = strlen(patch->old_name);\n+\t\tif (len > state->max_len)\n+\t\t\tstate->max_len = len;\n+\t}\n+\tif (patch->new_name) {\n+\t\tint len = quote_c_style(patch->new_name, NULL, NULL, 0);\n+\t\tif (!len)\n+\t\t\tlen = strlen(patch->new_name);\n+\t\tif (len > state->max_len)\n+\t\t\tstate->max_len = len;\n+\t}\n+}\n+\n+static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)\n+{\n+\tif (state->update_index) {\n+\t\tif (remove_file_from_cache(patch->old_name) < 0)\n+\t\t\treturn error(_(\"unable to remove %s from index\"), patch->old_name);\n+\t}\n+\tif (!state->cached) {\n+\t\tif (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {\n+\t\t\tremove_path(patch->old_name);\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static int add_index_file(struct apply_state *state,\n+\t\t\t  const char *path,\n+\t\t\t  unsigned mode,\n+\t\t\t  void *buf,\n+\t\t\t  unsigned long size)\n+{\n+\tstruct stat st;\n+\tstruct cache_entry *ce;\n+\tint namelen = strlen(path);\n+\tunsigned ce_size = cache_entry_size(namelen);\n+\n+\tif (!state->update_index)\n+\t\treturn 0;\n+\n+\tce = xcalloc(1, ce_size);\n+\tmemcpy(ce->name, path, namelen);\n+\tce->ce_mode = create_ce_mode(mode);\n+\tce->ce_flags = create_ce_flags(0);\n+\tce->ce_namelen = namelen;\n+\tif (S_ISGITLINK(mode)) {\n+\t\tconst char *s;\n+\n+\t\tif (!skip_prefix(buf, \"Subproject commit \", &s) ||\n+\t\t    get_oid_hex(s, &ce->oid)) {\n \t\t\tfree(ce);\n-\t\t\treturn error(_(\"corrupt patch for submodule %s\"), path);\n+\t\t       return error(_(\"corrupt patch for submodule %s\"), path);\n \t\t}\n \t} else {\n \t\tif (!state->cached) {\n-- \n2.13.0-rc2-265-gd6850fbf8f\n\n"}]}