]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sha1_name.c
remote.c: report specific errors from branch_get_upstream
[thirdparty/git.git] / sha1_name.c
index 95f9f8fa1a72693757bbafe0f2a7773d8ae2de05..461157a5bcd4fccf43c31d9074ec596d7d028add 100644 (file)
@@ -757,7 +757,7 @@ static int get_describe_name(const char *name, int len, unsigned char *sha1)
 
        for (cp = name + len - 1; name + 2 <= cp; cp--) {
                char ch = *cp;
-               if (hexval(ch) & ~0377) {
+               if (!isxdigit(ch)) {
                        /* We must be looking at g in "SOMETHING-g"
                         * for it to be describe output.
                         */
@@ -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,