summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2015-05-21 20:49:11 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-05-22 09:32:34 -0700
commit979cb245e29b35812d2d71a04069ba7a4580981f (patch)
tree52ae37718da691696524e25cc7286e3d929a9571 /wt-status.c
parentremote.c: untangle error logic in branch_get_upstream (diff)
downloadtgif-979cb245e29b35812d2d71a04069ba7a4580981f.tar.xz
remote.c: return upstream name from stat_tracking_info
After calling stat_tracking_info, callers often want to print the name of the upstream branch (in addition to the tracking count). To do this, they have to access branch->merge->dst[0] themselves. This is not wrong, as the return value from stat_tracking_info tells us whether we have an upstream branch or not. But it is a bit leaky, as we make an assumption about how it calculated the upstream name. Instead, let's add an out-parameter that lets the caller know the upstream name we found. As a bonus, we can get rid of the unusual tri-state return from the function. We no longer need to use it to differentiate between "no tracking config" and "tracking ref does not exist" (since you can check the upstream_name for that), so we can just use the usual 0/-1 convention for success/error. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/wt-status.c b/wt-status.c
index 853419f05f..4313b9d845 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1532,21 +1532,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
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 */
+ if (stat_tracking_info(branch, &num_ours, &num_theirs, &base) < 0) {
+ if (!base) {
+ fputc(s->null_termination ? '\0' : '\n', s->fp);
+ return;
+ }
+
upstream_is_gone = 1;
- break;
- default:
- /* with base */
- break;
}
- base = branch->merge[0]->dst;
base = shorten_unambiguous_ref(base, 0);
color_fprintf(s->fp, header_color, "...");
color_fprintf(s->fp, branch_color_remote, "%s", base);