]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs.c: use skip_prefix() in prettify_refname()
authorSZEDER Gábor <szeder.dev@gmail.com>
Thu, 23 Mar 2017 15:50:12 +0000 (16:50 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Mar 2017 18:22:01 +0000 (11:22 -0700)
This eliminates three magic numbers.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c

diff --git a/refs.c b/refs.c
index 62055ab09103acd8301ce8c70e7d903da3fc9439..49a7e703d53b3a3ffe7d9f6a006fe1819c9ed5e9 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -346,11 +346,11 @@ int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
 
 const char *prettify_refname(const char *name)
 {
-       return name + (
-               starts_with(name, "refs/heads/") ? 11 :
-               starts_with(name, "refs/tags/") ? 10 :
-               starts_with(name, "refs/remotes/") ? 13 :
-               0);
+       if (skip_prefix(name, "refs/heads/", &name) ||
+           skip_prefix(name, "refs/tags/", &name) ||
+           skip_prefix(name, "refs/remotes/", &name))
+               ; /* nothing */
+       return name;
 }
 
 static const char *ref_rev_parse_rules[] = {