Skip to content

Commit b6975ab

Browse files
committed
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>
1 parent 6d21bf9 commit b6975ab

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

wt-status.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "diffcore.h"
1010
#include "quote.h"
1111
#include "run-command.h"
12+
#include "remote.h"
1213

1314
int wt_status_relative_paths = 1;
1415
int wt_status_use_color = -1;
@@ -315,6 +316,25 @@ static void wt_status_print_verbose(struct wt_status *s)
315316
run_diff_index(&rev, 1);
316317
}
317318

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+
318338
void wt_status_print(struct wt_status *s)
319339
{
320340
unsigned char sha1[20];
@@ -333,6 +353,8 @@ void wt_status_print(struct wt_status *s)
333353
}
334354
color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
335355
color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
356+
if (!s->is_initial)
357+
wt_status_print_tracking(s);
336358
}
337359

338360
if (s->is_initial) {

0 commit comments

Comments
 (0)