diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2007-04-16 16:05:10 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-04-16 16:51:11 -0700 |
commit | ca135e7acc06f7d24ead732d2a1a531428da7135 (patch) | |
tree | 5a56e061f15602736847ec608839619cf377e09c /log-tree.c | |
parent | a59b276e18f3d4a548caf549e05188cb1bd3a709 (diff) | |
download | git-ca135e7acc06f7d24ead732d2a1a531428da7135.tar.gz git-ca135e7acc06f7d24ead732d2a1a531428da7135.tar.xz |
Add support for "commit name decorations" to log family of commands
This adds "--decorate" as a log option, which prints out the ref names
of any commits that are shown.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'log-tree.c')
-rw-r--r-- | log-tree.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/log-tree.c b/log-tree.c index dad551323..300b73356 100644 --- a/log-tree.c +++ b/log-tree.c @@ -4,6 +4,8 @@ #include "log-tree.h" #include "reflog-walk.h" +struct decoration name_decoration = { "object names" }; + static void show_parents(struct commit *commit, int abbrev) { struct commit_list *p; @@ -13,6 +15,23 @@ static void show_parents(struct commit *commit, int abbrev) } } +static void show_decorations(struct commit *commit) +{ + const char *prefix; + struct name_decoration *decoration; + + decoration = lookup_decoration(&name_decoration, &commit->object); + if (!decoration) + return; + prefix = " ("; + while (decoration) { + printf("%s%s", prefix, decoration->name); + prefix = ", "; + decoration = decoration->next; + } + putchar(')'); +} + /* * Search for "^[-A-Za-z]+: [^@]+@" pattern. It usually matches * Signed-off-by: and Acked-by: lines. @@ -136,6 +155,7 @@ void show_log(struct rev_info *opt, const char *sep) fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout); if (opt->parents) show_parents(commit, abbrev_commit); + show_decorations(commit); putchar(opt->diffopt.line_termination); return; } @@ -240,6 +260,7 @@ void show_log(struct rev_info *opt, const char *sep) printf(" (from %s)", diff_unique_abbrev(parent->object.sha1, abbrev_commit)); + show_decorations(commit); printf("%s", diff_get_color(opt->diffopt.color_diff, DIFF_RESET)); putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n'); |