From: Greg Price Date: Tue, 22 Dec 2009 22:22:38 GMT Subject: [PATCH 2/4] log --decorate=full: drop the "tag: " prefix Message-ID: <20091222222238.GW30538@dr-wily.mit.edu> In-Reply-To: <20091222222032.GU30538@dr-wily.mit.edu> The "tag: " prefix complicates machine parsing of decorations, so we drop it from the output formats intended to be parsed by machine, namely --decorate=full and the %D format code. The prefix is helpful for a human reader to see that the ref is an (annotated) tag, especially since we omit the "refs/tags/" prefix in the default output of "git log --decorate". In a script, however, it is easy to use "git cat-file -t" to distinguish annotated tags from commits when the distinction is relevant. Signed-off-by: Greg Price --- log-tree.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/log-tree.c b/log-tree.c index 0fdf159..5eb6b00 100644 --- a/log-tree.c +++ b/log-tree.c @@ -22,17 +22,18 @@ static void add_name_decoration(const char *prefix, const char *name, struct obj static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data) { + int short_refs = !!(!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS); struct object *obj = parse_object(sha1); if (!obj) return 0; - if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS) + if (short_refs) refname = prettify_refname(refname); add_name_decoration("", refname, obj); while (obj->type == OBJ_TAG) { obj = ((struct tag *)obj)->tagged; if (!obj) break; - add_name_decoration("tag: ", refname, obj); + add_name_decoration(short_refs ? "tag: " : "", refname, obj); } return 0; } -- 1.6.6.rc1.9.g2ad41.dirty