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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <pclouds@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]