{"thread":{"id":"6756","subject":"[PATCH] diff.c: Reuse the pprint_rename function for diff --summary output.","startedAt":"2007-02-10T14:36:47Z","lastAt":"2007-02-10T14:36:47Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"34101","messageId":"87mz3mdqps.fsf@wine.dyndns.org","threadId":"6756","inReplyTo":null,"subject":"[PATCH] diff.c: Reuse the pprint_rename function for diff --summary output.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-02-10T14:36:47Z","receivedAt":"2007-02-10T14:36:47Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"This avoids some code duplication, and yields more readable results\nfor directory renames.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n diff.c |   31 ++++---------------------------\n 1 files changed, 4 insertions(+), 27 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex ad476f7..4c642d7 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2430,34 +2430,11 @@ static void show_mode_change(struct diff_filepair *p, int show_name)\n \n static void show_rename_copy(const char *renamecopy, struct diff_filepair *p)\n {\n-\tconst char *old, *new;\n+\tchar *names = pprint_rename(p->one->path, p->two->path);\n \n-\t/* Find common prefix */\n-\told = p->one->path;\n-\tnew = p->two->path;\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->one->path 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->one->path)\n-\t\tprintf(\" %s %.*s{%s => %s} (%d%%)\\n\", renamecopy,\n-\t\t       (int)(old - p->one->path), p->one->path,\n-\t\t       old, new, (int)(0.5 + p->score * 100.0/MAX_SCORE));\n-\telse\n-\t\tprintf(\" %s %s => %s (%d%%)\\n\", renamecopy,\n-\t\t       p->one->path, p->two->path,\n-\t\t       (int)(0.5 + p->score * 100.0/MAX_SCORE));\n+\tprintf(\" %s %s (%d%%)\\n\", renamecopy, names,\n+\t       (int)(0.5 + p->score * 100.0/MAX_SCORE));\n+\tfree(names);\n \tshow_mode_change(p, 0);\n }\n \n-- \n1.5.0.rc4.31.g6289\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}