From 979cb245e29b35812d2d71a04069ba7a4580981f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 21 May 2015 20:49:11 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- remote.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'remote.h') diff --git a/remote.h b/remote.h index 03ca0058fe..357a90963d 100644 --- a/remote.h +++ b/remote.h @@ -239,7 +239,8 @@ enum match_refs_flags { }; /* Reporting of tracking info */ -int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs); +int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs, + const char **upstream_name); int format_tracking_info(struct branch *branch, struct strbuf *sb); struct ref *get_local_heads(void); -- cgit v1.3-5-g9baa