diff options
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/sha1_name.c b/sha1_name.c index 6d10f052b5..461157a5bc 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -1059,27 +1059,16 @@ static const char *get_upstream_branch(const char *branch_buf, int len) { char *branch = xstrndup(branch_buf, len); struct branch *upstream = branch_get(*branch ? branch : NULL); + struct strbuf err = STRBUF_INIT; + const char *ret; - /* - * Upstream can be NULL only if branch refers to HEAD and HEAD - * points to something different than a branch. - */ - if (!upstream) - die(_("HEAD does not point to a branch")); - if (!upstream->merge || !upstream->merge[0]->dst) { - if (!ref_exists(upstream->refname)) - die(_("No such branch: '%s'"), branch); - if (!upstream->merge) { - die(_("No upstream configured for branch '%s'"), - upstream->name); - } - die( - _("Upstream branch '%s' not stored as a remote-tracking branch"), - upstream->merge[0]->src); - } free(branch); - return upstream->merge[0]->dst; + ret = branch_get_upstream(upstream, &err); + if (!ret) + die("%s", err.buf); + + return ret; } static int interpret_upstream_mark(const char *name, int namelen, |