Skip to content

Commit 3e5b36c

Browse files
szedergitster
authored andcommitted
refs.c: use skip_prefix() in prettify_refname()
This eliminates three magic numbers. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3808ca commit 3e5b36c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

refs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
346346

347347
const char *prettify_refname(const char *name)
348348
{
349-
return name + (
350-
starts_with(name, "refs/heads/") ? 11 :
351-
starts_with(name, "refs/tags/") ? 10 :
352-
starts_with(name, "refs/remotes/") ? 13 :
353-
0);
349+
if (skip_prefix(name, "refs/heads/", &name) ||
350+
skip_prefix(name, "refs/tags/", &name) ||
351+
skip_prefix(name, "refs/remotes/", &name))
352+
; /* nothing */
353+
return name;
354354
}
355355

356356
static const char *ref_rev_parse_rules[] = {

0 commit comments

Comments
 (0)