Subject: [PATCH 12/12] refs.c: use skip_prefix() in prune_ref()

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Wed, 18 Dec 2013 21:53:57 +0700

This removes the magic number 5, which is the string length of
"refs/". This comes from get_loose_refs(), called in packed_refs().

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 refs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/refs.c b/refs.c
index 1fb658f..217093f 100644
--- a/refs.c
+++ b/refs.c
@@ -2318,7 +2318,8 @@ static void try_remove_empty_parents(char *name)
 /* make sure nobody touched the ref, and unlink */
 static void prune_ref(struct ref_to_prune *r)
 {
-	struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
+	const char *name = skip_prefix_defval(r->name, "refs/", r->name);
+	struct ref_lock *lock = lock_ref_sha1(name, r->sha1);
 
 	if (lock) {
 		unlink_or_warn(git_path("%s", r->name));
-- 
1.8.5.1.208.g019362e