{"thread":{"id":"43255","subject":"Re: [PATCH] Add file addition/deletion indicator in diffstat","startedAt":"2006-11-11T12:33:31Z","lastAt":"2006-12-17T00:23:13Z","messageCount":4,"participants":["Nguyen Thai Ngoc Duy","pclouds@gmail.com","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"296133","messageId":"20061111123331.GA23829@localhost","threadId":"43255","inReplyTo":null,"subject":"[PATCH] Add file addition/deletion indicator in diffstat","fromName":"","fromEmail":"pclouds@gmail.com","sentAt":"2006-11-11T12:33:31Z","receivedAt":"2006-11-11T12:33:31Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"For new files, \" (new)\" will be appended to filenames.\nFor deleted files, \" (deleted)\" will be appended to filenames.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c |   29 +++++++++++++++++++++++++++++\n 1 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 3315378..bd78138 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -599,6 +599,8 @@ struct diffstat_t {\n \t\tunsigned is_unmerged:1;\n \t\tunsigned is_binary:1;\n \t\tunsigned is_renamed:1;\n+\t\tunsigned is_added:1;\n+\t\tunsigned is_deleted:1;\n \t\tunsigned int added, deleted;\n \t} **files;\n };\n@@ -707,6 +709,10 @@ static void show_stats(struct diffstat_t\n \t\t}\n \n \t\tlen = strlen(file->name);\n+\t\tif (file->is_added)\n+\t\t\tlen += 6; /* \" (new)\" */\n+\t\tif (file->is_deleted)\n+\t\t\tlen += 10; /* \" (deleted)\" */\n \t\tif (max_len < len)\n \t\t\tmax_len = len;\n \n@@ -735,12 +741,25 @@ static void show_stats(struct diffstat_t\n \t\tint added = data->files[i]->added;\n \t\tint deleted = data->files[i]->deleted;\n \t\tint name_len;\n+\t\tchar *new_name = NULL;\n \n \t\t/*\n \t\t * \"scale\" the filename\n \t\t */\n \t\tlen = name_width;\n \t\tname_len = strlen(name);\n+\t\tif (data->files[i]->is_added) {\n+\t\t\tnew_name = name = xmalloc(name_len+7);  /* \" (new)\" */\n+\t\t\tmemcpy(name,data->files[i]->name,name_len);\n+\t\t\tmemcpy(name+name_len,\" (new)\",7);\n+\t\t\tname_len += 6;\n+\t\t}\n+\t\tif (data->files[i]->is_deleted) {\n+\t\t\tnew_name = name = xmalloc(name_len+11);  /* \" (deleted)\" */\n+\t\t\tmemcpy(name,data->files[i]->name,name_len);\n+\t\t\tmemcpy(name+name_len,\" (deleted)\",11);\n+\t\t\tname_len += 10; /* \" (deleted)\" */\n+\t\t}\n \t\tif (name_width < name_len) {\n \t\t\tchar *slash;\n \t\t\tprefix = \"...\";\n@@ -787,6 +806,8 @@ static void show_stats(struct diffstat_t\n \t\tshow_graph('-', del, del_c, reset);\n \t\tputchar('\\n');\n \tfree_diffstat_file:\n+\t\tif (new_name)\n+\t\t\tfree(new_name);\n \t\tfree(data->files[i]->name);\n \t\tfree(data->files[i]);\n \t}\n@@ -1067,6 +1088,14 @@ static void builtin_diffstat(const char\n \t\tdata->is_unmerged = 1;\n \t\treturn;\n \t}\n+\tif (DIFF_FILE_VALID(one)) {\n+\t\tif (!DIFF_FILE_VALID(two))\n+\t\t\tdata->is_deleted = 1;\n+\t}\n+\telse {\n+\t\tif (DIFF_FILE_VALID(two))\n+\t\t\tdata->is_added = 1;\n+\t}\n \tif (complete_rewrite) {\n \t\tdiff_populate_filespec(one, 0);\n \t\tdiff_populate_filespec(two, 0);\n-- \n"},{"id":"298117","messageId":"fcaeb9bf0612161612r36470c2fm3c0f19e56f6a16a@mail.gmail.com","threadId":"43255","inReplyTo":"20061111123331.GA23829@localhost","subject":"Re: [PATCH] Add file addition/deletion indicator in diffstat","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2006-12-17T00:12:58Z","receivedAt":"2006-12-17T00:12:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Hi Junio,\n\nI have used this patch for a while and found it actually useful,\nespecially while inspecting \"git-log --stat\". And if you prefer \"git\ndiff --stat\" over \"git status\", it may tell you which file you added\nor deleted. So my only guess is that you missed it somehow. If it is\nrefused, may I know the reason? I can improve it on request :-)\n\nOn 11/11/06, pclouds@gmail.com <pclouds@gmail.com> wrote:\n> For new files, \" (new)\" will be appended to filenames.\n> For deleted files, \" (deleted)\" will be appended to filenames.\n-- \n"},{"id":"296841","messageId":"7vhcvv8jjb.fsf@assigned-by-dhcp.cox.net","threadId":"43255","inReplyTo":"fcaeb9bf0612161612r36470c2fm3c0f19e56f6a16a@mail.gmail.com","subject":"Re: [PATCH] Add file addition/deletion indicator in diffstat","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-17T00:15:20Z","receivedAt":"2006-12-17T00:15:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n\n> I have used this patch for a while and found it actually useful,\n> especially while inspecting \"git-log --stat\". And if you prefer \"git\n> diff --stat\" over \"git status\", it may tell you which file you added\n> or deleted. So my only guess is that you missed it somehow. If it is\n> refused, may I know the reason? I can improve it on request :-)\n\nDoesn't seem to add much value over existing --summary.\n"},{"id":"294151","messageId":"fcaeb9bf0612161623lae7410dy458d25ac33f41e0c@mail.gmail.com","threadId":"43255","inReplyTo":"7vhcvv8jjb.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add file addition/deletion indicator in diffstat","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2006-12-17T00:23:13Z","receivedAt":"2006-12-17T00:23:13Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 12/17/06, Junio C Hamano <junkio@cox.net> wrote:\n> \"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n>\n> > I have used this patch for a while and found it actually useful,\n> > especially while inspecting \"git-log --stat\". And if you prefer \"git\n> > diff --stat\" over \"git status\", it may tell you which file you added\n> > or deleted. So my only guess is that you missed it somehow. If it is\n> > refused, may I know the reason? I can improve it on request :-)\n>\n> Doesn't seem to add much value over existing --summary.\n\nOh.. I didn't know that option. Sorry for the noise.\n-- \n"}]}