diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-09-20 12:26:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-20 12:26:57 -0700 |
commit | 2e6e3e82ee36b3e1bec1db8db24817270080424e (patch) | |
tree | d2fd031f798ec11b95c04c0c8ec48426f3c420cd /wt-status.c | |
parent | 238504b014230d0bc244fb0de84990863fcddd59 (diff) | |
parent | f223459bec106bbe211a01321e48c050a9cad25e (diff) | |
download | git-2e6e3e82ee36b3e1bec1db8db24817270080424e.tar.gz |
Merge branch 'jx/branch-vv-always-compare-with-upstream'
"git branch -v -v" (and "git status") did not distinguish among a
branch that does not build on any other branch, a branch that is in
sync with the branch it builds on, and a branch that is configured
to build on some other branch that no longer exists.
* jx/branch-vv-always-compare-with-upstream:
status: always show tracking branch even no change
branch: report invalid tracking branch as gone
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/wt-status.c b/wt-status.c index ff4b32426a..c8c2d77524 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1363,6 +1363,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s) const char *base; const char *branch_name; int num_ours, num_theirs; + int upstream_is_gone = 0; color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## "); @@ -1380,20 +1381,37 @@ static void wt_shortstatus_print_tracking(struct wt_status *s) branch = branch_get(s->branch + 11); if (s->is_initial) color_fprintf(s->fp, header_color, _("Initial commit on ")); - if (!stat_tracking_info(branch, &num_ours, &num_theirs)) { - color_fprintf(s->fp, branch_color_local, "%s", branch_name); + + color_fprintf(s->fp, branch_color_local, "%s", branch_name); + + switch (stat_tracking_info(branch, &num_ours, &num_theirs)) { + case 0: + /* no base */ fputc(s->null_termination ? '\0' : '\n', s->fp); return; + case -1: + /* with "gone" base */ + upstream_is_gone = 1; + break; + default: + /* with base */ + break; } base = branch->merge[0]->dst; base = shorten_unambiguous_ref(base, 0); - color_fprintf(s->fp, branch_color_local, "%s", branch_name); color_fprintf(s->fp, header_color, "..."); color_fprintf(s->fp, branch_color_remote, "%s", base); + if (!upstream_is_gone && !num_ours && !num_theirs) { + fputc(s->null_termination ? '\0' : '\n', s->fp); + return; + } + color_fprintf(s->fp, header_color, " ["); - if (!num_ours) { + if (upstream_is_gone) { + color_fprintf(s->fp, header_color, _("gone")); + } else if (!num_ours) { color_fprintf(s->fp, header_color, _("behind ")); color_fprintf(s->fp, branch_color_remote, "%d", num_theirs); } else if (!num_theirs) { |