1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-10 20:26:14 +02:00

resolve_ref(): use prefixcmp()

Terminate the link content string one step earlier, allowing
prefixcmp() to be used instead of the less clear memcmp().

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty 2011-09-15 23:10:32 +02:00 committed by Junio C Hamano
parent 7bb2bf8e5c
commit b54cb79597

4
refs.c
View File

@ -520,8 +520,8 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
len = readlink(path, buffer, sizeof(buffer)-1);
if (len < 0)
return NULL;
if (len >= 5 && !memcmp("refs/", buffer, 5)) {
buffer[len] = 0;
buffer[len] = 0;
if (!prefixcmp(buffer, "refs/")) {
strcpy(ref_buffer, buffer);
ref = ref_buffer;
if (flag)