Skip to content

Commit 6765524

Browse files
felipecgitster
authored andcommitted
remote: refactor code into alloc_delete_ref()
Will be useful in next patches. No functional changes. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent db70a04 commit 6765524

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

remote.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -978,16 +978,20 @@ static void tail_link_ref(struct ref *ref, struct ref ***tail)
978978
*tail = &ref->next;
979979
}
980980

981+
static struct ref *alloc_delete_ref(void)
982+
{
983+
struct ref *ref = alloc_ref("(delete)");
984+
hashclr(ref->new_sha1);
985+
return ref;
986+
}
987+
981988
static struct ref *try_explicit_object_name(const char *name)
982989
{
983990
unsigned char sha1[20];
984991
struct ref *ref;
985992

986-
if (!*name) {
987-
ref = alloc_ref("(delete)");
988-
hashclr(ref->new_sha1);
989-
return ref;
990-
}
993+
if (!*name)
994+
return alloc_delete_ref();
991995
if (get_sha1(name, sha1))
992996
return NULL;
993997
ref = alloc_ref(name);

0 commit comments

Comments
 (0)