Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v2] pretty: add %D format specifier

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:02:32

Harry Jeffery [off-list ref] writes:
Add a new format specifier, '%D' that is identical in behaviour to '%d',
except that it does not include the ' (' prefix or ')' suffix provided
by '%d'.

Signed-off-by: Harry Jeffery <redacted>
---
The patch is broken and does not apply with "git am" here.  Please
first try sending a patch to yourself and make sure it comes through
OK.

Thanks.
quoted hunk
diff --git a/log-tree.h b/log-tree.h
index d6ecd4d..b26160c 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -13,7 +13,13 @@ int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
 int log_tree_opt_parse(struct rev_info *, const char **, int);
 void show_log(struct rev_info *opt);
-void format_decorations(struct strbuf *sb, const struct commit
*commit, int use_color);
+void format_decorations_extended(struct strbuf *sb, const struct
commit *commit,
Broken lines...
+			     int use_color,
+			     const char *prefix,
+			     const char *separator,
+			     const char *suffix);
+#define format_decorations(strbuf, commit, color) \
+			     format_decorations_extended((strbuf),
(commit), (color), " (", ", ", ")")
Broken line here, too.
quoted hunk
 void show_decorations(struct rev_info *opt, struct commit *commit);
 void log_write_email_headers(struct rev_info *opt, struct commit *commit,
 			     const char **subject_p,
diff --git a/pretty.c b/pretty.c
index 44b9f64..46d65b9 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1197,6 +1197,10 @@ static size_t format_commit_one(struct strbuf
*sb, /* in UTF-8 */
 		load_ref_decorations(DECORATE_SHORT_REFS);
 		format_decorations(sb, commit, c->auto_color);
 		return 1;
+	case 'D':
+		load_ref_decorations(DECORATE_SHORT_REFS);
+		format_decorations_extended(sb, commit, c->auto_color, "", ", ", "");
+		return 1;
 	case 'g':		/* reflog info */
 		switch(placeholder[1]) {
 		case 'd':	/* reflog selector */
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index de0cc4a..38148c1 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -457,4 +457,15 @@ EOF
 	test_cmp expected actual1
 '

+test_expect_success 'clean log decoration' '
+	git log --no-walk --tags --pretty="%H %D" --decorate=full >actual &&
+	cat <<EOF >expected &&
+$head1 tag: refs/tags/tag2
+$head2 tag: refs/tags/message-one
+$old_head1 tag: refs/tags/message-two
+EOF
+	sort actual >actual1 &&
+	test_cmp expected actual1
+'
+
 test_done
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help