From 3a429d0af342d85ef6d561e3a60ae8793a34ae78 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 21 May 2015 00:45:32 -0400 Subject: remote.c: report specific errors from branch_get_upstream 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 another callsite, and means we can use the helper in other locations that want to give the same error messages. The logic and error messages come straight from sha1_name.c, with the exception that we start each error with a lowercase letter, as is our usual style (note that a few tests need updated as a result). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/branch.c | 2 +- builtin/for-each-ref.c | 2 +- builtin/log.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/branch.c b/builtin/branch.c index bd1fa0b43a..b7202b3399 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -123,7 +123,7 @@ static int branch_merged(int kind, const char *name, if (kind == REF_LOCAL_BRANCH) { struct branch *branch = branch_get(name); - const char *upstream = branch_get_upstream(branch); + const char *upstream = branch_get_upstream(branch, NULL); unsigned char sha1[20]; if (upstream && diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index dc2a201a45..18d209bc9a 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -664,7 +664,7 @@ static void populate_value(struct refinfo *ref) continue; branch = branch_get(ref->refname + 11); - refname = branch_get_upstream(branch); + refname = branch_get_upstream(branch, NULL); if (!refname) continue; } else if (starts_with(name, "color:")) { diff --git a/builtin/log.c b/builtin/log.c index fb61c08ee5..6faeb82c8e 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1632,7 +1632,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) break; default: current_branch = branch_get(NULL); - upstream = branch_get_upstream(current_branch); + upstream = branch_get_upstream(current_branch, NULL); if (!upstream) { fprintf(stderr, _("Could not find a tracked" " remote branch, please" -- cgit v1.2.3