Re: [PATCH v3 08/14] remote.c: report specific errors from branch_get_upstream

2015-05-21 Thread Jeff King
On Thu, May 21, 2015 at 11:33:58AM -0700, Junio C Hamano wrote: +static const char *error_buf(struct strbuf *err, const char *fmt, ...) { - if (!branch || !branch-merge || !branch-merge[0]) - return NULL; + if (err) { + va_list ap; + va_start(ap,

Re: [PATCH v3 08/14] remote.c: report specific errors from branch_get_upstream

2015-05-21 Thread Junio C Hamano
Jeff King p...@peff.net writes: diff --git a/remote.c b/remote.c index dca3442..1b7051a 100644 --- a/remote.c +++ b/remote.c @@ -1705,10 +1705,35 @@ int branch_merge_matches(struct branch *branch, return refname_match(branch-merge[i]-src, refname); } -const char

Re: [PATCH v3 08/14] remote.c: report specific errors from branch_get_upstream

2015-05-21 Thread Jeff King
On Thu, May 21, 2015 at 12:25:57PM -0700, Junio C Hamano wrote: Note also that the original may dereference branch-merge[0] even if it is NULL. I think that can't actually happen in practice (we only allocate branch-merge if we have at least one item to put in it, and all of the checks of

Re: [PATCH v3 08/14] remote.c: report specific errors from branch_get_upstream

2015-05-21 Thread Jeff King
On Thu, May 21, 2015 at 08:46:43PM -0400, Jeff King wrote: On Thu, May 21, 2015 at 12:25:57PM -0700, Junio C Hamano wrote: Note also that the original may dereference branch-merge[0] even if it is NULL. I think that can't actually happen in practice (we only allocate branch-merge if

Re: [PATCH v3 08/14] remote.c: report specific errors from branch_get_upstream

2015-05-21 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Thu, May 21, 2015 at 11:33:58AM -0700, Junio C Hamano wrote: +static const char *error_buf(struct strbuf *err, const char *fmt, ...) { - if (!branch || !branch-merge || !branch-merge[0]) - return NULL; + if (err) { + va_list

[PATCH v3 08/14] remote.c: report specific errors from branch_get_upstream

2015-05-20 Thread Jeff King
When the previous commit introduced the branch_get_upstream helper, there was one call-site that could not be converted: the one in sha1_name.c, which gives detailed error messages for each possible failure. Let's teach the helper to optionally report these specific errors. This lets us convert