{"thread":{"id":"23668","subject":"[PATCH] Show branch information in short output of git status","startedAt":"2010-05-02T10:10:21Z","lastAt":"2010-05-02T10:10:21Z","messageCount":1,"participants":["Knittl"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"140750","messageId":"AANLkTim335DkD5nq8njM3jfEDcWLH-4cdEHKRdavdDLG@mail.gmail.com","threadId":"23668","inReplyTo":null,"subject":"[PATCH] Show branch information in short output of git status","fromName":"Knittl","fromEmail":"knittl89@googlemail.com","sentAt":"2010-05-02T10:10:21Z","receivedAt":"2010-05-02T10:10:21Z","isPatch":true,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":">From 6a82c5486163a058cf2bdbe5089527084a563b80 Mon Sep 17 00:00:00 2001\nFrom: Daniel Knittl-Frank <knittl89+git@googlemail.com>\nDate: Tue, 20 Apr 2010 22:40:54 +0200\nSubject: [PATCH] Show branch information in short output of git status\n\nThis patch adds a first line in the output of `git status -s`, showing\nwhich branch the user is currently on, and in case of tracking branches\nthe number of commits on each branch.\n\nSigned-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n---\n wt-status.c |   45 +++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 45 insertions(+), 0 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 8ca59a2..2e6c56e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -9,6 +9,7 @@\n #include \"quote.h\"\n #include \"run-command.h\"\n #include \"remote.h\"\n+#include \"refs.h\"\n\n static char default_wt_status_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_NORMAL, /* WT_STATUS_HEADER */\n@@ -721,9 +722,53 @@ static void wt_shortstatus_untracked(int\nnull_termination, struct string_list_it\n \t}\n }\n\n+static void wt_shortstatus_print_tracking(struct wt_status *s)\n+{\n+\tstruct branch *branch;\n+\tconst char *branch_color = color(WT_STATUS_HEADER, s);\n+\n+\tconst char *base;\n+\tconst char *branch_name;\n+\tint num_ours, num_theirs;\n+\n+\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"## \");\n+\n+\tif(!s->branch) return;\n+\tbranch_name = s->branch;\n+\n+\tif (!prefixcmp(branch_name, \"refs/heads/\"))\n+\t\tbranch_name += 11;\n+\telse if (!strcmp(branch_name, \"HEAD\")) {\n+\t\tbranch_color = color(WT_STATUS_NOBRANCH, s);\n+\t}\n+\n+\tbranch = branch_get(s->branch + 11);\n+\tif (!stat_tracking_info(branch, &num_ours, &num_theirs)) {\n+\n+\t\tif(s->is_initial) {\n+\t\t\tcolor_fprintf(s->fp,\n+\t\t\t\tcolor(WT_STATUS_HEADER, s),\n+\t\t\t\t\"Initial commit ... \");\n+\t\t}\n+\t\tcolor_fprintf_ln(s->fp, branch_color,\n+\t\t\t\"%s\", branch_name);\n+\t\treturn;\n+\t}\n+\n+\tbase = branch->merge[0]->dst;\n+\tbase = shorten_unambiguous_ref(base, 0);\n+\tcolor_fprintf_ln(s->fp, branch_color,\n+\t\t\t\"%s (%d) ... %s (%d)\",\n+\t\t\tbranch_name, num_ours,\n+\t\t\tbase, num_theirs);\n+}\n+\n void wt_shortstatus_print(struct wt_status *s, int null_termination)\n {\n \tint i;\n+\n+\twt_shortstatus_print_tracking(s);\n+\n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tstruct wt_status_change_data *d;\n \t\tstruct string_list_item *it;\n-- \n1.7.1.rc2.6.g1015.dirty\n\n-- \ntyped with http://neo-layout.org\nmyFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!\n"}]}