summaryrefslogtreecommitdiff
path: root/builtin/name-rev.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2019-11-26 15:23:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-27 02:21:18 (GMT)
commit2059e79c0dac1e1e4e55733618dc6ca9d00b8aa4 (patch)
treeb2ddd64b25ac399c7d407ef45b11efcdab7f2592 /builtin/name-rev.c
parent1768aaf01d3f57af8c4182d5887d219456f4a094 (diff)
downloadgit-2059e79c0dac1e1e4e55733618dc6ca9d00b8aa4.zip
git-2059e79c0dac1e1e4e55733618dc6ca9d00b8aa4.tar.gz
git-2059e79c0dac1e1e4e55733618dc6ca9d00b8aa4.tar.bz2
name-rev: use skip_prefix() instead of starts_with()
Let skip_prefix() advance refname to get rid of two magic numbers. Signed-off-by: René Scharfe <l.s.r@web.de> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/name-rev.c')
-rw-r--r--builtin/name-rev.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index b0f0776..e55a4f0 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -161,10 +161,10 @@ static const char *name_ref_abbrev(const char *refname, int shorten_unambiguous)
{
if (shorten_unambiguous)
refname = shorten_unambiguous_ref(refname, 0);
- else if (starts_with(refname, "refs/heads/"))
- refname = refname + 11;
- else if (starts_with(refname, "refs/"))
- refname = refname + 5;
+ else if (skip_prefix(refname, "refs/heads/", &refname))
+ ; /* refname already advanced */
+ else
+ skip_prefix(refname, "refs/", &refname);
return refname;
}