remote: refactor code into alloc_delete_ref()
Will be useful in next patches. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Feb 23, 2012 at 00:43 UTC
676552464a871564835e1cb9d0484277b1b75e79
1 file changed
+9
-5
remote.c
+9
-5
@@ -978,16 +978,20 @@ static void tail_link_ref(struct ref *ref, struct ref ***tail)
978
*tail = &ref->next;
979
}
980
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
+
988
static struct ref *try_explicit_object_name(const char *name)
989
{
990
unsigned char sha1[20];
991
struct ref *ref;
992
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();
995
if (get_sha1(name, sha1))
996
return NULL;
997
ref = alloc_ref(name);