summaryrefslogtreecommitdiff
path: root/builtin/for-each-ref.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/for-each-ref.c')
-rw-r--r--builtin/for-each-ref.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 92bd2b2..2bd19ca 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -659,10 +659,12 @@ static void populate_value(struct refinfo *ref)
else if (starts_with(name, "symref"))
refname = ref->symref ? ref->symref : "";
else if (starts_with(name, "upstream")) {
+ const char *branch_name;
/* only local branches may have an upstream */
- if (!starts_with(ref->refname, "refs/heads/"))
+ if (!skip_prefix(ref->refname, "refs/heads/",
+ &branch_name))
continue;
- branch = branch_get(ref->refname + 11);
+ branch = branch_get(branch_name);
refname = branch_get_upstream(branch, NULL);
if (!refname)