From 4602c17d8911e14d537f6f87db02faab6e3f5d69 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 7 Dec 2007 17:19:31 -0800 Subject: [PATCH 1/4] git-shortlog -e: show e-mail address as well This option shows the author's email address next to the name. Signed-off-by: Junio C Hamano --- builtin-shortlog.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/builtin-shortlog.c b/builtin-shortlog.c index b9cc134443..13df0c668d 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -11,6 +11,7 @@ static const char shortlog_usage[] = "git-shortlog [-n] [-s] [... ]"; static char *common_repo_prefix; +static int email; static int compare_by_number(const void *a1, const void *a2) { @@ -57,6 +58,14 @@ static void insert_one_record(struct path_list *list, len--; namebuf[len] = '\0'; } + else + len = strlen(namebuf); + + if (email) { + size_t room = sizeof(namebuf) - len - 1; + int maillen = eoemail - boemail + 1; + snprintf(namebuf + len, room, " %.*s", maillen, boemail); + } buffer = xstrdup(namebuf); item = path_list_insert(buffer, list); @@ -219,6 +228,9 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) else if (!strcmp(argv[1], "-s") || !strcmp(argv[1], "--summary")) summary = 1; + else if (!strcmp(argv[1], "-e") || + !strcmp(argv[1], "--email")) + email = 1; else if (!prefixcmp(argv[1], "-w")) { wrap_lines = 1; parse_wrap_args(argv[1], &in1, &in2, &wrap); From 6508bb75f675a09f410ab55b842510d36c373c43 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 11 Dec 2007 07:33:12 -0500 Subject: [PATCH 2/4] shortlog: document -e option This shows e-mail address in addition to author's name. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- Documentation/git-shortlog.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt index 2220ef6ea8..e14720b73f 100644 --- a/Documentation/git-shortlog.txt +++ b/Documentation/git-shortlog.txt @@ -8,8 +8,8 @@ git-shortlog - Summarize 'git log' output SYNOPSIS -------- [verse] -git-log --pretty=short | 'git-shortlog' [-h] [-n] [-s] -git-shortlog [-n|--numbered] [-s|--summary] [...] +git-log --pretty=short | 'git-shortlog' [-h] [-n] [-s] [-e] +git-shortlog [-n|--numbered] [-s|--summary] [-e|--email] [...] DESCRIPTION ----------- @@ -32,6 +32,9 @@ OPTIONS -s, \--summary:: Suppress commit description and provide a commit count summary only. +-e, \--email:: + Show the email address of each author. + FILES ----- From 97566ea72ea460576ccaea7b51dd32ab33e1c46c Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Tue, 11 Dec 2007 15:43:51 +0100 Subject: [PATCH 3/4] Invert numbers and names in the git-shortlog summary mode. Also make it `cut` friendly using a tab to separate the numbers and names. Signed-off-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- builtin-shortlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 13df0c668d..90666cbd78 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -265,7 +265,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) struct path_list *onelines = list.items[i].util; if (summary) { - printf("%s: %d\n", list.items[i].path, onelines->nr); + printf("%6d\t%s\n", onelines->nr, list.items[i].path); } else { printf("%s (%d):\n", list.items[i].path, onelines->nr); for (j = onelines->nr - 1; j >= 0; j--) { From 3384a2dfc12f0fecd25ecfd6bfa9ee0d82517bf2 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 11 Dec 2007 10:09:04 -0800 Subject: [PATCH 4/4] shortlog: default to HEAD when the standard input is a tty Instead of warning the user that it is expecting git log output from the standard input (and waiting for the user to type the log from the keyboard, which is a silly thing to do), default to traverse from HEAD when there is no rev parameter given and the standard input is a tty. This factors out a useful helper "add_head()" from builtin-diff.c to a more appropriate place revision.c while renaming it to more descriptive name add_head_to_pending(), as that is what the function is about. Signed-off-by: Junio C Hamano --- builtin-diff.c | 14 +------------- builtin-log.c | 5 +---- builtin-shortlog.c | 5 +++-- revision.c | 12 ++++++++++++ revision.h | 2 ++ 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/builtin-diff.c b/builtin-diff.c index 1b615991e1..55fb84c730 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -176,18 +176,6 @@ static int builtin_diff_combined(struct rev_info *revs, return 0; } -void add_head(struct rev_info *revs) -{ - unsigned char sha1[20]; - struct object *obj; - if (get_sha1("HEAD", sha1)) - return; - obj = parse_object(sha1); - if (!obj) - return; - add_pending_object(revs, obj, "HEAD"); -} - static void refresh_index_quietly(void) { struct lock_file *lock_file; @@ -272,7 +260,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) if (!strcmp(arg, "--")) break; else if (!strcmp(arg, "--cached")) { - add_head(&rev); + add_head_to_pending(&rev); if (!rev.pending.nr) die("No HEAD commit to compare with (yet)"); break; diff --git a/builtin-log.c b/builtin-log.c index e1f1cf6714..d375c9dbf9 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -18,9 +18,6 @@ static int default_show_root = 1; static const char *fmt_patch_subject_prefix = "PATCH"; -/* this is in builtin-diff.c */ -void add_head(struct rev_info *revs); - static void add_name_decoration(const char *prefix, const char *name, struct object *obj) { int plen = strlen(prefix); @@ -746,7 +743,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) * does not have. */ rev.pending.objects[0].item->flags |= UNINTERESTING; - add_head(&rev); + add_head_to_pending(&rev); } /* * Otherwise, it is "format-patch -22 HEAD", and/or diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 90666cbd78..3d8d7094ab 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -249,9 +249,10 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) read_mailmap(&mailmap, ".mailmap", &common_repo_prefix); + /* assume HEAD if from a tty */ + if (!rev.pending.nr && isatty(0)) + add_head_to_pending(&rev); if (rev.pending.nr == 0) { - if (isatty(0)) - fprintf(stderr, "(reading log to summarize from standard input)\n"); read_from_stdin(&list); } else diff --git a/revision.c b/revision.c index 2a59035192..7e2f4f1eb5 100644 --- a/revision.c +++ b/revision.c @@ -139,6 +139,18 @@ void add_pending_object(struct rev_info *revs, struct object *obj, const char *n add_pending_object_with_mode(revs, obj, name, S_IFINVALID); } +void add_head_to_pending(struct rev_info *revs) +{ + unsigned char sha1[20]; + struct object *obj; + if (get_sha1("HEAD", sha1)) + return; + obj = parse_object(sha1); + if (!obj) + return; + add_pending_object(revs, obj, "HEAD"); +} + static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags) { struct object *object; diff --git a/revision.h b/revision.h index 992e1e9dd5..8572315954 100644 --- a/revision.h +++ b/revision.h @@ -130,6 +130,8 @@ extern void add_object(struct object *obj, extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name); +extern void add_head_to_pending(struct rev_info *); + enum commit_action { commit_ignore, commit_show,