* [PATCH] Add file addition/deletion indicator in diffstat
@ 2006-11-11 12:33 pclouds
2006-12-17 0:12 ` Nguyen Thai Ngoc Duy
0 siblings, 1 reply; 4+ messages in thread
From: pclouds @ 2006-11-11 12:33 UTC (permalink / raw)
To: git
For new files, " (new)" will be appended to filenames.
For deleted files, " (deleted)" will be appended to filenames.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
diff.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index 3315378..bd78138 100644
--- a/diff.c
+++ b/diff.c
@@ -599,6 +599,8 @@ struct diffstat_t {
unsigned is_unmerged:1;
unsigned is_binary:1;
unsigned is_renamed:1;
+ unsigned is_added:1;
+ unsigned is_deleted:1;
unsigned int added, deleted;
} **files;
};
@@ -707,6 +709,10 @@ static void show_stats(struct diffstat_t
}
len = strlen(file->name);
+ if (file->is_added)
+ len += 6; /* " (new)" */
+ if (file->is_deleted)
+ len += 10; /* " (deleted)" */
if (max_len < len)
max_len = len;
@@ -735,12 +741,25 @@ static void show_stats(struct diffstat_t
int added = data->files[i]->added;
int deleted = data->files[i]->deleted;
int name_len;
+ char *new_name = NULL;
/*
* "scale" the filename
*/
len = name_width;
name_len = strlen(name);
+ if (data->files[i]->is_added) {
+ new_name = name = xmalloc(name_len+7); /* " (new)" */
+ memcpy(name,data->files[i]->name,name_len);
+ memcpy(name+name_len," (new)",7);
+ name_len += 6;
+ }
+ if (data->files[i]->is_deleted) {
+ new_name = name = xmalloc(name_len+11); /* " (deleted)" */
+ memcpy(name,data->files[i]->name,name_len);
+ memcpy(name+name_len," (deleted)",11);
+ name_len += 10; /* " (deleted)" */
+ }
if (name_width < name_len) {
char *slash;
prefix = "...";
@@ -787,6 +806,8 @@ static void show_stats(struct diffstat_t
show_graph('-', del, del_c, reset);
putchar('\n');
free_diffstat_file:
+ if (new_name)
+ free(new_name);
free(data->files[i]->name);
free(data->files[i]);
}
@@ -1067,6 +1088,14 @@ static void builtin_diffstat(const char
data->is_unmerged = 1;
return;
}
+ if (DIFF_FILE_VALID(one)) {
+ if (!DIFF_FILE_VALID(two))
+ data->is_deleted = 1;
+ }
+ else {
+ if (DIFF_FILE_VALID(two))
+ data->is_added = 1;
+ }
if (complete_rewrite) {
diff_populate_filespec(one, 0);
diff_populate_filespec(two, 0);
--
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Add file addition/deletion indicator in diffstat
2006-11-11 12:33 [PATCH] Add file addition/deletion indicator in diffstat pclouds
@ 2006-12-17 0:12 ` Nguyen Thai Ngoc Duy
2006-12-17 0:15 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2006-12-17 0:12 UTC (permalink / raw)
To: git, Junio C Hamano
Hi Junio,
I have used this patch for a while and found it actually useful,
especially while inspecting "git-log --stat". And if you prefer "git
diff --stat" over "git status", it may tell you which file you added
or deleted. So my only guess is that you missed it somehow. If it is
refused, may I know the reason? I can improve it on request :-)
On 11/11/06, pclouds@gmail.com <pclouds@gmail.com> wrote:
> For new files, " (new)" will be appended to filenames.
> For deleted files, " (deleted)" will be appended to filenames.
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add file addition/deletion indicator in diffstat
2006-12-17 0:12 ` Nguyen Thai Ngoc Duy
@ 2006-12-17 0:15 ` Junio C Hamano
2006-12-17 0:23 ` Nguyen Thai Ngoc Duy
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2006-12-17 0:15 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git
"Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:
> I have used this patch for a while and found it actually useful,
> especially while inspecting "git-log --stat". And if you prefer "git
> diff --stat" over "git status", it may tell you which file you added
> or deleted. So my only guess is that you missed it somehow. If it is
> refused, may I know the reason? I can improve it on request :-)
Doesn't seem to add much value over existing --summary.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add file addition/deletion indicator in diffstat
2006-12-17 0:15 ` Junio C Hamano
@ 2006-12-17 0:23 ` Nguyen Thai Ngoc Duy
0 siblings, 0 replies; 4+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2006-12-17 0:23 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On 12/17/06, Junio C Hamano <junkio@cox.net> wrote:
> "Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:
>
> > I have used this patch for a while and found it actually useful,
> > especially while inspecting "git-log --stat". And if you prefer "git
> > diff --stat" over "git status", it may tell you which file you added
> > or deleted. So my only guess is that you missed it somehow. If it is
> > refused, may I know the reason? I can improve it on request :-)
>
> Doesn't seem to add much value over existing --summary.
Oh.. I didn't know that option. Sorry for the noise.
--
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-12-17 0:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-11 12:33 [PATCH] Add file addition/deletion indicator in diffstat pclouds
2006-12-17 0:12 ` Nguyen Thai Ngoc Duy
2006-12-17 0:15 ` Junio C Hamano
2006-12-17 0:23 ` Nguyen Thai Ngoc Duy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.