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>
This commit is contained in:

committed by
Junio C Hamano

parent
1ca41a1932
commit
979cb245e2
@ -716,7 +716,7 @@ static void populate_value(struct refinfo *ref)
|
||||
char buf[40];
|
||||
|
||||
if (stat_tracking_info(branch, &num_ours,
|
||||
&num_theirs) != 1)
|
||||
&num_theirs, NULL))
|
||||
continue;
|
||||
|
||||
if (!num_ours && !num_theirs)
|
||||
@ -738,7 +738,7 @@ static void populate_value(struct refinfo *ref)
|
||||
assert(branch);
|
||||
|
||||
if (stat_tracking_info(branch, &num_ours,
|
||||
&num_theirs) != 1)
|
||||
&num_theirs, NULL))
|
||||
continue;
|
||||
|
||||
if (!num_ours && !num_theirs)
|
||||
|
Reference in New Issue
Block a user