{"thread":{"id":"35116","subject":"[PATCH try2 0/2] branch: improve verbose option","startedAt":"2013-10-12T07:00:27Z","lastAt":"2013-10-12T07:00:29Z","messageCount":3,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"228775","messageId":"1381561229-19947-1-git-send-email-felipe.contreras@gmail.com","threadId":"35116","inReplyTo":null,"subject":"[PATCH try2 0/2] branch: improve verbose option","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-10-12T07:00:27Z","receivedAt":"2013-10-12T07:00:27Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This has been discussed before:\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/224489\n\nbut in the spirit of the perfect being the enemy of the good, nothing got done.\n\nThis series makes 'git branch -v' much faster, and gives us the most important\ninformation; the configured upstream tracking branch. Showing ahead/behind is\nnot as important, specially considering that currently 'git branch -v' doesn't\nshow the branch we are comparing the ahead/behind to.\n\nStrictly speaking it's a regression, but nobody would complain, and if somebody\ndoes, it should be easy to revert if needed.\n\nFelipe Contreras (2):\n  branch: trivial cleanup\n  branch: reorganize verbose options\n\n builtin/branch.c         | 33 +++++++++++++++------------------\n t/t6040-tracking-info.sh |  8 ++++----\n 2 files changed, 19 insertions(+), 22 deletions(-)\n\n-- \n1.8.4-fc\n"},{"id":"228776","messageId":"1381561229-19947-2-git-send-email-felipe.contreras@gmail.com","threadId":"35116","inReplyTo":"1381561229-19947-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH try2 1/2] branch: trivial cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-10-12T07:00:28Z","receivedAt":"2013-10-12T07:00:28Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"No functional changes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/branch.c | 19 +++++++++----------\n 1 file changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0836890..ac17b18 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -425,16 +425,15 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,\n \tstruct strbuf fancy = STRBUF_INIT;\n \n \tif (!stat_tracking_info(branch, &ours, &theirs)) {\n-\t\tif (branch && branch->merge && branch->merge[0]->dst &&\n-\t\t    show_upstream_ref) {\n-\t\t\tref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);\n-\t\t\tif (want_color(branch_use_color))\n-\t\t\t\tstrbuf_addf(stat, \"[%s%s%s] \",\n-\t\t\t\t\t\tbranch_get_color(BRANCH_COLOR_UPSTREAM),\n-\t\t\t\t\t\tref, branch_get_color(BRANCH_COLOR_RESET));\n-\t\t\telse\n-\t\t\t\tstrbuf_addf(stat, \"[%s] \", ref);\n-\t\t}\n+\t\tif (!branch || !branch->merge || !branch->merge[0]->dst || !show_upstream_ref)\n+\t\t\treturn;\n+\t\tref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);\n+\t\tif (want_color(branch_use_color))\n+\t\t\tstrbuf_addf(stat, \"[%s%s%s] \",\n+\t\t\t\t\tbranch_get_color(BRANCH_COLOR_UPSTREAM),\n+\t\t\t\t\tref, branch_get_color(BRANCH_COLOR_RESET));\n+\t\telse\n+\t\t\tstrbuf_addf(stat, \"[%s] \", ref);\n \t\treturn;\n \t}\n \n-- \n1.8.4-fc\n"},{"id":"228777","messageId":"1381561229-19947-3-git-send-email-felipe.contreras@gmail.com","threadId":"35116","inReplyTo":"1381561229-19947-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH try2 2/2] branch: reorganize verbose options","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-10-12T07:00:29Z","receivedAt":"2013-10-12T07:00:29Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Showing the upstream tracking branch is more important than how many\ncommits are ahead/behind, so now 'git branch -v' shows the upstream, but\nnot the tracking info, and 'git branch -vv' shows all information (as\nbefore).\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/branch.c         | 22 ++++++++++------------\n t/t6040-tracking-info.sh |  8 ++++----\n 2 files changed, 14 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex ac17b18..baa1d31 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -417,15 +417,15 @@ static int ref_cmp(const void *r1, const void *r2)\n }\n \n static void fill_tracking_info(struct strbuf *stat, const char *branch_name,\n-\t\tint show_upstream_ref)\n+\t\tint show_tracking)\n {\n \tint ours, theirs;\n \tchar *ref = NULL;\n \tstruct branch *branch = branch_get(branch_name);\n \tstruct strbuf fancy = STRBUF_INIT;\n \n-\tif (!stat_tracking_info(branch, &ours, &theirs)) {\n-\t\tif (!branch || !branch->merge || !branch->merge[0]->dst || !show_upstream_ref)\n+\tif (!show_tracking || !stat_tracking_info(branch, &ours, &theirs)) {\n+\t\tif (!branch || !branch->merge || !branch->merge[0]->dst)\n \t\t\treturn;\n \t\tref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);\n \t\tif (want_color(branch_use_color))\n@@ -437,15 +437,13 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,\n \t\treturn;\n \t}\n \n-\tif (show_upstream_ref) {\n-\t\tref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);\n-\t\tif (want_color(branch_use_color))\n-\t\t\tstrbuf_addf(&fancy, \"%s%s%s\",\n-\t\t\t\t\tbranch_get_color(BRANCH_COLOR_UPSTREAM),\n-\t\t\t\t\tref, branch_get_color(BRANCH_COLOR_RESET));\n-\t\telse\n-\t\t\tstrbuf_addstr(&fancy, ref);\n-\t}\n+\tref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);\n+\tif (want_color(branch_use_color))\n+\t\tstrbuf_addf(&fancy, \"%s%s%s\",\n+\t\t\t\tbranch_get_color(BRANCH_COLOR_UPSTREAM),\n+\t\t\t\tref, branch_get_color(BRANCH_COLOR_RESET));\n+\telse\n+\t\tstrbuf_addstr(&fancy, ref);\n \n \tif (!ours) {\n \t\tif (ref)\ndiff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh\nindex ec2b516..86e80eb 100755\n--- a/t/t6040-tracking-info.sh\n+++ b/t/t6040-tracking-info.sh\n@@ -36,10 +36,10 @@ test_expect_success setup '\n \n script='s/^..\\(b.\\)[\t 0-9a-f]*\\[\\([^]]*\\)\\].*/\\1 \\2/p'\n cat >expect <<\\EOF\n-b1 ahead 1, behind 1\n-b2 ahead 1, behind 1\n-b3 behind 1\n-b4 ahead 2\n+b1 origin/master\n+b2 origin/master\n+b3 origin/master\n+b4 origin/master\n EOF\n \n test_expect_success 'branch -v' '\n-- \n1.8.4-fc\n"}]}