From: Santhosh Kumar Mani <santhoshmani@gmail.com>
To: git@vger.kernel.org
Subject: [RFC/PATCH] show tracking branches with their associated branch names
Date: Sat, 10 Dec 2011 13:10:29 +0530 [thread overview]
Message-ID: <1323502829.1698.6.camel@sdesktop> (raw)
The "git branch" command, by default, displays the local branches. There
is no visual distinction made between the tracking branches and normal
local branches. This patch enables the "git branch" to display
tracking info for tracking branches:
Before this patch:
$ git branch
* master
local
After this patch:
$ git branch
* master [origin/master]
local
Signed-off-by: Santhosh Kumar Mani <santhoshmani@gmail.com>
---
builtin/branch.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index e1e486e..4841416 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -373,6 +373,19 @@ static int ref_cmp(const void *r1, const void *r2)
return strcmp(c1->name, c2->name);
}
+static int get_tracking_branch_name(struct strbuf *name, const char
*branch_name)
+{
+ struct branch *branch = branch_get(branch_name);
+
+ if (branch && branch->merge && branch->merge[0]->dst) {
+ strbuf_addf(name, " [%s]",
+ shorten_unambiguous_ref(branch->merge[0]->dst, 0));
+ return 1;
+ }
+
+ return 0;
+}
+
static void fill_tracking_info(struct strbuf *stat, const char
*branch_name,
int show_upstream_ref)
{
@@ -475,6 +488,9 @@ static void print_ref_item(struct ref_item *item,
int maxwidth, int verbose,
else if (verbose)
/* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */
add_verbose_info(&out, item, verbose, abbrev);
+ else if (get_tracking_branch_name(&out, item->name))
+ ;
+
printf("%s\n", out.buf);
strbuf_release(&name);
strbuf_release(&out);
--
1.7.0.4
next reply other threads:[~2011-12-10 7:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-10 7:40 Santhosh Kumar Mani [this message]
2011-12-10 9:53 ` [RFC/PATCH] show tracking branches with their associated branch names Vincent van Ravesteijn
2011-12-10 11:23 ` Santhosh Kumar Mani
2011-12-12 7:14 ` Junio C Hamano
2011-12-12 14:19 ` Santhosh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323502829.1698.6.camel@sdesktop \
--to=santhoshmani@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).