[PATCH v2 04/11] resolve_ref_unsafe(): use skip_prefix() to skip over "ref:"

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

 



From: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>

This requires buf to be declared (const char *), which is how it is
used anyway.

Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx>
---
 refs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/refs.c b/refs.c
index 771941b..020ee3f 100644
--- a/refs.c
+++ b/refs.c
@@ -1416,7 +1416,7 @@ const char *resolve_ref_unsafe(const char *refname, unsigned char *sha1, int rea
 	for (;;) {
 		char path[PATH_MAX];
 		struct stat st;
-		char *buf;
+		const char *buf;
 		int fd;
 
 		if (--depth < 0) {
@@ -1497,11 +1497,10 @@ const char *resolve_ref_unsafe(const char *refname, unsigned char *sha1, int rea
 			len--;
 		buffer[len] = '\0';
 
-		if (starts_with(buffer, "ref:")) {
+		if (skip_prefix(buffer, "ref:", &buf)) {
 			/* It is a symbolic ref */
 			if (flag)
 				*flag |= REF_ISSYMREF;
-			buf = buffer + 4;
 			while (isspace(*buf))
 				buf++;
 			if (check_refname_format(buf, REFNAME_ALLOW_ONELEVEL)) {
-- 
2.1.1

--
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]