git-status: show the remote tracking statistics
This teaches "git status" to show the same remote tracking statistics "git checkout" gives at the beginning of the output. Now the necessary low-level machinery is properly factored out, we can do this quite cleanly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 2, 2008 at 00:52 UTC
b6975ab59b07e5416b3f9b6f077d3cb50ef5ac7e
1 file changed
+22
wt-status.c
+22
@@ -9,6 +9,7 @@
9
#include "diffcore.h"
10
#include "quote.h"
11
#include "run-command.h"
12
+#include "remote.h"
13
14
int wt_status_relative_paths = 1;
15
int wt_status_use_color = -1;
@@ -315,6 +316,25 @@ static void wt_status_print_verbose(struct wt_status *s)
316
run_diff_index(&rev, 1);
317
}
318
319
+static void wt_status_print_tracking(struct wt_status *s)
320
+{
321
+ struct strbuf sb = STRBUF_INIT;
322
+ const char *cp, *ep;
323
+ struct branch *branch;
324
+
325
+ assert(s->branch && !s->is_initial);
326
+ if (prefixcmp(s->branch, "refs/heads/"))
327
+ return;
328
+ branch = branch_get(s->branch + 11);
329
+ if (!format_tracking_info(branch, &sb))
330
+ return;
331
+
332
+ for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
333
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
334
+ "# %.*s", (int)(ep - cp), cp);
335
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
336
+}
337
+
338
void wt_status_print(struct wt_status *s)
339
{
340
unsigned char sha1[20];
@@ -333,6 +353,8 @@ void wt_status_print(struct wt_status *s)
353
}
354
color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
355
color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
356
+ if (!s->is_initial)
357
+ wt_status_print_tracking(s);
358
}
359
360
if (s->is_initial) {