match_refs: search ref list tail internally

Avoid code duplication by moving list tail search to match_refs().

This does not change the semantics, except for http-push, which now inserts
to the front of the ref list in order to get rid of the global remote_tail.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Clemens Buchacher
2009-05-31 16:26:48 +02:00
committed by Junio C Hamano
parent 6a01554e63
commit 6d2bf96e55
6 changed files with 23 additions and 29 deletions

View File

@ -1844,7 +1844,7 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)
return 1;
}
static struct ref *remote_refs, **remote_tail;
static struct ref *remote_refs;
static void one_remote_ref(char *refname)
{
@ -1874,13 +1874,12 @@ static void one_remote_ref(char *refname)
}
}
*remote_tail = ref;
remote_tail = &ref->next;
ref->next = remote_refs;
remote_refs = ref;
}
static void get_dav_remote_heads(void)
{
remote_tail = &remote_refs;
remote_ls("refs/", (PROCESS_FILES | PROCESS_DIRS | RECURSIVE), process_ls_ref, NULL);
}
@ -2311,9 +2310,7 @@ int main(int argc, char **argv)
}
/* match them up */
if (!remote_tail)
remote_tail = &remote_refs;
if (match_refs(local_refs, remote_refs, &remote_tail,
if (match_refs(local_refs, &remote_refs,
nr_refspec, (const char **) refspec, push_all)) {
rc = -1;
goto cleanup;