Add %m to '--pretty=format:'
When used with '--boundary A...B', this shows the -/</> marker you would get with --left-right option to 'git-log' family. When symmetric diff is not used, everybody is shown to be on the "right" branch. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 9, 2007 at 02:34 UTC
199c45bf2b168cb8b2231e45f35e5fd588c2fc19
2 files changed
+14
-3
Documentation/pretty-formats.txt
+1
@@ -117,6 +117,7 @@ The placeholders are:
117
- '%Cgreen': switch color to green
118
- '%Cblue': switch color to blue
119
- '%Creset': reset color
120
+- '%m': left, right or boundary mark
121
- '%n': newline
122
123
commit.c
+13
-3
@@ -4,6 +4,8 @@
4
#include "pkt-line.h"
5
#include "utf8.h"
6
#include "interpolate.h"
7
+#include "diff.h"
8
+#include "revision.h"
9
10
int save_commit_buffer = 1;
11
@@ -808,7 +810,8 @@ static long format_commit_message(const struct commit *commit,
810
{ "%Cgreen" }, /* green */
811
{ "%Cblue" }, /* blue */
812
{ "%Creset" }, /* reset color */
811
- { "%n" } /* newline */
813
+ { "%n" }, /* newline */
814
+ { "%m" }, /* left/right/bottom */
815
};
816
enum interp_index {
817
IHASH = 0, IHASH_ABBREV,
@@ -824,14 +827,15 @@ static long format_commit_message(const struct commit *commit,
827
ISUBJECT,
828
IBODY,
829
IRED, IGREEN, IBLUE, IRESET_COLOR,
827
- INEWLINE
830
+ INEWLINE,
831
+ ILEFT_RIGHT,
832
};
833
struct commit_list *p;
834
char parents[1024];
835
int i;
836
enum { HEADER, SUBJECT, BODY } state;
837
834
- if (INEWLINE + 1 != ARRAY_SIZE(table))
838
+ if (ILEFT_RIGHT + 1 != ARRAY_SIZE(table))
839
die("invalid interp table!");
840
841
/* these are independent of the commit */
@@ -852,6 +856,12 @@ static long format_commit_message(const struct commit *commit,
856
interp_set_entry(table, ITREE_ABBREV,
857
find_unique_abbrev(commit->tree->object.sha1,
858
DEFAULT_ABBREV));
859
+ interp_set_entry(table, ILEFT_RIGHT,
860
+ (commit->object.flags & BOUNDARY)
861
+ ? "-"
862
+ : (commit->object.flags & SYMMETRIC_LEFT)
863
+ ? "<"
864
+ : ">");
865
866
parents[1] = 0;
867
for (i = 0, p = commit->parents;