diff options
author | Jeff King <peff@peff.net> | 2015-05-21 00:45:51 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-22 09:33:08 -0700 |
commit | 3dbe9db01bd9c0b0701f72a631ac15b1791f6642 (patch) | |
tree | b70424662931f9288f085918fa830299ef0f8961 /builtin | |
parent | adfe5d04345631299f9a4518d56c6dd3d47eb0b3 (diff) | |
download | git-3dbe9db01bd9c0b0701f72a631ac15b1791f6642.tar.gz git-3dbe9db01bd9c0b0701f72a631ac15b1791f6642.tar.xz |
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/for-each-ref.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 92bd2b266..2bd19caa9 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) |