{"thread":{"id":"29126","subject":"[RFC/PATCH] show tracking branches with their associated branch names","startedAt":"2011-12-10T07:40:29Z","lastAt":"2011-12-12T14:19:54Z","messageCount":5,"participants":["Santhosh Kumar Mani","Vincent van Ravesteijn","Junio C Hamano","Santhosh"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"180747","messageId":"1323502829.1698.6.camel@sdesktop","threadId":"29126","inReplyTo":null,"subject":"[RFC/PATCH] show tracking branches with their associated branch names","fromName":"Santhosh Kumar Mani","fromEmail":"santhoshmani@gmail.com","sentAt":"2011-12-10T07:40:29Z","receivedAt":"2011-12-10T07:40:29Z","isPatch":true,"sender":{"key":"santhoshmani@gmail.com","avatar":null},"body":"The \"git branch\" command, by default, displays the local branches. There\nis no visual distinction made between the tracking branches and normal\nlocal branches. This patch enables the \"git branch\" to display\ntracking info for tracking branches:\n\nBefore this patch:\n  $ git branch\n  * master\n    local\n\nAfter this patch:\n  $ git branch\n  * master [origin/master]\n    local\n\nSigned-off-by: Santhosh Kumar Mani <santhoshmani@gmail.com>\n---\n builtin/branch.c |   16 ++++++++++++++++\n 1 files changed, 16 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex e1e486e..4841416 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -373,6 +373,19 @@ static int ref_cmp(const void *r1, const void *r2)\n \treturn strcmp(c1->name, c2->name);\n }\n \n+static int get_tracking_branch_name(struct strbuf *name, const char\n*branch_name)\n+{\n+\tstruct branch *branch = branch_get(branch_name);\n+\n+\tif (branch && branch->merge && branch->merge[0]->dst) {\n+\t\tstrbuf_addf(name, \" [%s]\",\n+\t\t\t\tshorten_unambiguous_ref(branch->merge[0]->dst, 0));\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static void fill_tracking_info(struct strbuf *stat, const char\n*branch_name,\n \t\tint show_upstream_ref)\n {\n@@ -475,6 +488,9 @@ static void print_ref_item(struct ref_item *item,\nint maxwidth, int verbose,\n \telse if (verbose)\n \t\t/* \" f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h\" */\n \t\tadd_verbose_info(&out, item, verbose, abbrev);\n+\telse if (get_tracking_branch_name(&out, item->name))\n+\t\t;\n+\n \tprintf(\"%s\\n\", out.buf);\n \tstrbuf_release(&name);\n \tstrbuf_release(&out);\n-- \n1.7.0.4\n"},{"id":"180751","messageId":"4EE32C1B.8070306@lyx.org","threadId":"29126","inReplyTo":"1323502829.1698.6.camel@sdesktop","subject":"Re: [RFC/PATCH] show tracking branches with their associated branch names","fromName":"Vincent van Ravesteijn","fromEmail":"vfr@lyx.org","sentAt":"2011-12-10T09:53:31Z","receivedAt":"2011-12-10T09:53:31Z","isPatch":true,"sender":{"key":"vfr@lyx.org","avatar":"https://avatars.githubusercontent.com/u/687868?v=4"},"body":"Op 10-12-2011 8:40, Santhosh Kumar Mani schreef:\n> The \"git branch\" command, by default, displays the local branches. There\n> is no visual distinction made between the tracking branches and normal\n> local branches. This patch enables the \"git branch\" to display\n> tracking info for tracking branches:\n>\n> Before this patch:\n>    $ git branch\n>    * master\n>      local\n>\n> After this patch:\n>    $ git branch\n>    * master [origin/master]\n>      local\n>\n>\nDid you try \"git branch -vv\" ?\n\nVincent\n"},{"id":"180779","messageId":"1323516226.1698.80.camel@sdesktop","threadId":"29126","inReplyTo":"4EE32C1B.8070306@lyx.org","subject":"Re: [RFC/PATCH] show tracking branches with their associated branch names","fromName":"Santhosh Kumar Mani","fromEmail":"santhoshmani@gmail.com","sentAt":"2011-12-10T11:23:46Z","receivedAt":"2011-12-10T11:23:46Z","isPatch":true,"sender":{"key":"santhoshmani@gmail.com","avatar":null},"body":"On Sat, 2011-12-10 at 10:53 +0100, Vincent van Ravesteijn wrote:\n> Op 10-12-2011 8:40, Santhosh Kumar Mani schreef:\n> > The \"git branch\" command, by default, displays the local branches. There\n> > is no visual distinction made between the tracking branches and normal\n> > local branches. This patch enables the \"git branch\" to display\n> > tracking info for tracking branches:\n> >\n> > Before this patch:\n> >    $ git branch\n> >    * master\n> >      local\n> >\n> > After this patch:\n> >    $ git branch\n> >    * master [origin/master]\n> >      local\n> >\n> >\n> Did you try \"git branch -vv\" ?\n> \n\nYes. I did. It is too verbose as it meant to be.\n\nThis patch distinguishes between the tracking and non-tracking local\nbranches.\n\nI use a lot of tracking branches and they track different branches. I\ntend find this feature useful to know which branch tracks what.\n\nOf course, I could get this information in different ways. But it makes\nsense to have this information displayed by default.\n\n> Vincent\n\nRegards,\nSanthosh.\n"},{"id":"180912","messageId":"7vsjkq5h0i.fsf@alter.siamese.dyndns.org","threadId":"29126","inReplyTo":"1323516226.1698.80.camel@sdesktop","subject":"Re: [RFC/PATCH] show tracking branches with their associated branch names","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-12T07:14:58Z","receivedAt":"2011-12-12T07:14:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santhosh Kumar Mani <santhoshmani@gmail.com> writes:\n\n> Of course, I could get this information in different ways. But it makes\n> sense to have this information displayed by default.\n\nIt makes sense to make the various information available, but it does not\nmean it makes sense to add it by default for everybody at all. Given that\nagainst all common sense, many newbie web-tips and third-party documents\nsuggest \"git branch | sed -ne 's/^\\* //p'\" as a way to find the current\nbranch in scripts, I am sure such a change will cause trouble to many\nwhile only helping a few.\n\nI wouldn't mind a new option --verbose-format=... that takes various\nformatting letters similar to how --pretty=format:... does, though.\n"},{"id":"180929","messageId":"CABtqY3zwRooPUyPrLu3pf0fnHS+WP0XVKDFhZ1S0sR4cq=aP5A@mail.gmail.com","threadId":"29126","inReplyTo":"7vsjkq5h0i.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] show tracking branches with their associated branch names","fromName":"Santhosh","fromEmail":"santhoshmani@gmail.com","sentAt":"2011-12-12T14:19:54Z","receivedAt":"2011-12-12T14:19:54Z","isPatch":true,"sender":{"key":"santhoshmani@gmail.com","avatar":null},"body":"On Mon, Dec 12, 2011 at 12:44 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> It makes sense to make the various information available, but it does not\n> mean it makes sense to add it by default for everybody at all. Given that\n> against all common sense, many newbie web-tips and third-party documents\n> suggest \"git branch | sed -ne 's/^\\* //p'\" as a way to find the current\n> branch in scripts, I am sure such a change will cause trouble to many\n> while only helping a few.\n>\n\nYou certainly have a point.\n\n> I wouldn't mind a new option --verbose-format=... that takes various\n> formatting letters similar to how --pretty=format:... does, though.\n>\n\nI will explore this option and see if it is worth the trouble.\nProbably I can accomplish this locally with an alias.\n\n~Santhosh.\n"}]}