From: Jeff King Date: Thu, 21 May 2015 04:45:51 +0000 (-0400) Subject: for-each-ref: use skip_prefix instead of starts_with X-Git-Tag: v2.5.0-rc0~55^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3dbe9db01bd9c0b0701f72a631ac15b1791f6642 for-each-ref: use skip_prefix instead of starts_with This saves us having to maintain a magic number to skip past the matched prefix. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 92bd2b2665..2bd19caa9c 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)