* [RFC/PATCH] show tracking branches with their associated branch names
@ 2011-12-10 7:40 Santhosh Kumar Mani
2011-12-10 9:53 ` Vincent van Ravesteijn
0 siblings, 1 reply; 5+ messages in thread
From: Santhosh Kumar Mani @ 2011-12-10 7:40 UTC (permalink / raw)
To: git
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC/PATCH] show tracking branches with their associated branch names
2011-12-10 7:40 [RFC/PATCH] show tracking branches with their associated branch names Santhosh Kumar Mani
@ 2011-12-10 9:53 ` Vincent van Ravesteijn
2011-12-10 11:23 ` Santhosh Kumar Mani
0 siblings, 1 reply; 5+ messages in thread
From: Vincent van Ravesteijn @ 2011-12-10 9:53 UTC (permalink / raw)
To: Santhosh Kumar Mani; +Cc: git
Op 10-12-2011 8:40, Santhosh Kumar Mani schreef:
> 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
>
>
Did you try "git branch -vv" ?
Vincent
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC/PATCH] show tracking branches with their associated branch names
2011-12-10 9:53 ` Vincent van Ravesteijn
@ 2011-12-10 11:23 ` Santhosh Kumar Mani
2011-12-12 7:14 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Santhosh Kumar Mani @ 2011-12-10 11:23 UTC (permalink / raw)
To: Vincent van Ravesteijn; +Cc: git
On Sat, 2011-12-10 at 10:53 +0100, Vincent van Ravesteijn wrote:
> Op 10-12-2011 8:40, Santhosh Kumar Mani schreef:
> > 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
> >
> >
> Did you try "git branch -vv" ?
>
Yes. I did. It is too verbose as it meant to be.
This patch distinguishes between the tracking and non-tracking local
branches.
I use a lot of tracking branches and they track different branches. I
tend find this feature useful to know which branch tracks what.
Of course, I could get this information in different ways. But it makes
sense to have this information displayed by default.
> Vincent
Regards,
Santhosh.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC/PATCH] show tracking branches with their associated branch names
2011-12-10 11:23 ` Santhosh Kumar Mani
@ 2011-12-12 7:14 ` Junio C Hamano
2011-12-12 14:19 ` Santhosh
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2011-12-12 7:14 UTC (permalink / raw)
To: Santhosh Kumar Mani; +Cc: Vincent van Ravesteijn, git
Santhosh Kumar Mani <santhoshmani@gmail.com> writes:
> Of course, I could get this information in different ways. But it makes
> sense to have this information displayed by default.
It makes sense to make the various information available, but it does not
mean it makes sense to add it by default for everybody at all. Given that
against all common sense, many newbie web-tips and third-party documents
suggest "git branch | sed -ne 's/^\* //p'" as a way to find the current
branch in scripts, I am sure such a change will cause trouble to many
while only helping a few.
I wouldn't mind a new option --verbose-format=... that takes various
formatting letters similar to how --pretty=format:... does, though.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC/PATCH] show tracking branches with their associated branch names
2011-12-12 7:14 ` Junio C Hamano
@ 2011-12-12 14:19 ` Santhosh
0 siblings, 0 replies; 5+ messages in thread
From: Santhosh @ 2011-12-12 14:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Vincent van Ravesteijn, git
On Mon, Dec 12, 2011 at 12:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> It makes sense to make the various information available, but it does not
> mean it makes sense to add it by default for everybody at all. Given that
> against all common sense, many newbie web-tips and third-party documents
> suggest "git branch | sed -ne 's/^\* //p'" as a way to find the current
> branch in scripts, I am sure such a change will cause trouble to many
> while only helping a few.
>
You certainly have a point.
> I wouldn't mind a new option --verbose-format=... that takes various
> formatting letters similar to how --pretty=format:... does, though.
>
I will explore this option and see if it is worth the trouble.
Probably I can accomplish this locally with an alias.
~Santhosh.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-12-12 14:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-10 7:40 [RFC/PATCH] show tracking branches with their associated branch names Santhosh Kumar Mani
2011-12-10 9:53 ` 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
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).