Skip to contentSkip to conversation

Make the '%d' for log pretty format look the same as --decorate

PATCH New Nathan W. Panike 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make the '%d' for log pretty format look the same as --decorate

We teach git to add a "tag: " prefix to tag names when the '%d' pretty format option is given. It is then the same format as the --decorate option given directly to log.

---
 log-tree.c |    9 ---------
 log-tree.h |    9 +++++++++
 pretty.c   |    2 ++
 3 files changed, 11 insertions(+), 9 deletions(-)
log-tree.c +0 -9
index 2a1e3a9..9c24cbf 100644
@@ -11,15 +11,6 @@
 
 struct decoration name_decoration = { "object names" };
 
-enum decoration_type {
-	DECORATION_NONE = 0,
-	DECORATION_REF_LOCAL,
-	DECORATION_REF_REMOTE,
-	DECORATION_REF_TAG,
-	DECORATION_REF_STASH,
-	DECORATION_REF_HEAD,
-};
-
 static char decoration_colors[][COLOR_MAXLEN] = {
 	GIT_COLOR_RESET,
 	GIT_COLOR_BOLD_GREEN,	/* REF_LOCAL */
log-tree.h +9 -0
index 5c4cf7c..29861f0 100644
@@ -3,6 +3,15 @@
 
 #include "revision.h"
 
+enum decoration_type {
+	DECORATION_NONE = 0,
+	DECORATION_REF_LOCAL,
+	DECORATION_REF_REMOTE,
+	DECORATION_REF_TAG,
+	DECORATION_REF_STASH,
+	DECORATION_REF_HEAD,
+};
+
 struct log_info {
 	struct commit *commit, *parent;
 };
pretty.c +2 -0
index dff5c8d..8130556 100644
@@ -786,6 +786,8 @@ static void format_decoration(struct strbuf *sb, const struct commit *commit)
 	while (d) {
 		strbuf_addstr(sb, prefix);
 		prefix = ", ";
+		if(d->type == DECORATION_REF_TAG)
+			strbuf_addstr(sb, "tag: ");
 		strbuf_addstr(sb, d->name);
 		d = d->next;
 	}
Signature · 1 line
1.7.5.1