alloc_ref_from_str(): factor out a common pattern of alloc_ref from string
Also fix an underallocation in walker.c::interpret_target(). Signed-off-by: Krzysztof Kowalczyk <kkowalczyk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
1f8115b113
commit
737922aa64
3
walker.c
3
walker.c
@ -190,8 +190,7 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
|
||||
if (!get_sha1_hex(target, sha1))
|
||||
return 0;
|
||||
if (!check_ref_format(target)) {
|
||||
struct ref *ref = alloc_ref(strlen(target));
|
||||
strcpy(ref->name, target);
|
||||
struct ref *ref = alloc_ref_from_str(target);
|
||||
if (!walker->fetch_ref(walker, ref)) {
|
||||
hashcpy(sha1, ref->old_sha1);
|
||||
free(ref);
|
||||
|
Reference in New Issue
Block a user