git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] branch: colour upstream branches
@ 2013-04-14  1:46 Felipe Contreras
  2013-04-14 19:07 ` Thomas Rast
  2013-04-14 22:31 ` Duy Nguyen
  0 siblings, 2 replies; 10+ messages in thread
From: Felipe Contreras @ 2013-04-14  1:46 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy, Felipe Contreras

It's hard to see them among so much output otherwise.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/branch.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 00d17d2..a1cdc29 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -417,32 +417,45 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
 	int ours, theirs;
 	char *ref = NULL;
 	struct branch *branch = branch_get(branch_name);
+	char fancy[80];
 
 	if (!stat_tracking_info(branch, &ours, &theirs)) {
 		if (branch && branch->merge && branch->merge[0]->dst &&
-		    show_upstream_ref)
-			strbuf_addf(stat, "[%s] ",
-			    shorten_unambiguous_ref(branch->merge[0]->dst, 0));
+		    show_upstream_ref) {
+			ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+			if (want_color(branch_use_color))
+				strbuf_addf(stat, "[%s%s%s] ",
+						GIT_COLOR_BLUE, ref, GIT_COLOR_RESET);
+			else
+				strbuf_addf(stat, "[%s] ", ref);
+		}
 		return;
 	}
 
-	if (show_upstream_ref)
+	if (show_upstream_ref) {
 		ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+		if (want_color(branch_use_color))
+			snprintf(fancy, sizeof(fancy), "%s%s%s",
+					GIT_COLOR_BLUE, ref, GIT_COLOR_RESET);
+		else
+			strncpy(fancy, ref, sizeof(fancy));
+	}
+
 	if (!ours) {
 		if (ref)
-			strbuf_addf(stat, _("[%s: behind %d]"), ref, theirs);
+			strbuf_addf(stat, _("[%s: behind %d]"), fancy, theirs);
 		else
 			strbuf_addf(stat, _("[behind %d]"), theirs);
 
 	} else if (!theirs) {
 		if (ref)
-			strbuf_addf(stat, _("[%s: ahead %d]"), ref, ours);
+			strbuf_addf(stat, _("[%s: ahead %d]"), fancy, ours);
 		else
 			strbuf_addf(stat, _("[ahead %d]"), ours);
 	} else {
 		if (ref)
 			strbuf_addf(stat, _("[%s: ahead %d, behind %d]"),
-				    ref, ours, theirs);
+				    fancy, ours, theirs);
 		else
 			strbuf_addf(stat, _("[ahead %d, behind %d]"),
 				    ours, theirs);
-- 
1.8.2.1.641.gd16d37a

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-04-15  1:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-14  1:46 [PATCH] branch: colour upstream branches Felipe Contreras
2013-04-14 19:07 ` Thomas Rast
2013-04-14 22:31 ` Duy Nguyen
2013-04-14 23:22   ` Felipe Contreras
2013-04-14 23:46     ` Duy Nguyen
2013-04-14 23:54       ` Felipe Contreras
2013-04-15  0:55         ` Duy Nguyen
2013-04-15  1:24           ` Felipe Contreras
2013-04-15  1:31             ` Duy Nguyen
2013-04-15  1:35               ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).