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:
Krzysztof Kowalczyk
2008-05-10 16:26:58 -07:00
committed by Junio C Hamano
parent 1f8115b113
commit 737922aa64
6 changed files with 19 additions and 27 deletions

View File

@ -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);