summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a01554)
raw | patch | inline | side by side (parent: 6a01554)
author | Clemens Buchacher <drizzd@aon.at> | |
Sun, 31 May 2009 14:26:48 +0000 (16:26 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 2 Jun 2009 02:41:24 +0000 (19:41 -0700) |
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 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>
builtin-remote.c | patch | blob | history | |
builtin-send-pack.c | patch | blob | history | |
http-push.c | patch | blob | history | |
remote.c | patch | blob | history | |
remote.h | patch | blob | history | |
transport.c | patch | blob | history |
diff --git a/builtin-remote.c b/builtin-remote.c
index fda9a54a0c2f31b1071e4c401a3707375fc7a10d..9248e0aac79462261ba3cf2b21342c93c38fc1eb 100644 (file)
--- a/builtin-remote.c
+++ b/builtin-remote.c
struct ref_states *states)
{
struct remote *remote = states->remote;
- struct ref *ref, *local_refs, *push_map, **push_tail;
+ struct ref *ref, *local_refs, *push_map;
if (remote->mirror)
return 0;
local_refs = get_local_heads();
push_map = copy_ref_list(remote_refs);
- push_tail = &push_map;
- while (*push_tail)
- push_tail = &((*push_tail)->next);
- match_refs(local_refs, push_map, &push_tail, remote->push_refspec_nr,
+ match_refs(local_refs, &push_map, remote->push_refspec_nr,
remote->push_refspec, MATCH_REFS_NONE);
states->push.strdup_strings = 1;
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 473a3de40c4cc9aab5c1355d0602646234e7bc1c..0b3d00bfb914f9eadfa0b2613aaf6f08a577f1cc 100644 (file)
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
int fd[2];
struct child_process *conn;
struct extra_have_objects extra_have;
- struct ref *remote_refs, **remote_tail, *local_refs;
+ struct ref *remote_refs, *local_refs;
int ret;
int send_all = 0;
const char *receivepack = "git-receive-pack";
flags |= MATCH_REFS_MIRROR;
/* match them up */
- remote_tail = &remote_refs;
- while (*remote_tail)
- remote_tail = &((*remote_tail)->next);
- if (match_refs(local_refs, remote_refs, &remote_tail,
- nr_refspecs, refspecs, flags)) {
+ if (match_refs(local_refs, &remote_refs, nr_refspecs, refspecs, flags))
return -1;
- }
ret = send_pack(&args, fd, conn, remote_refs, &extra_have);
diff --git a/http-push.c b/http-push.c
index e16a0ad3f97ef49930a599d3a800a0c7fad317e0..35b3856a473d8c69d31b8885cab902ed787674e9 100644 (file)
--- a/http-push.c
+++ b/http-push.c
return 1;
}
-static struct ref *remote_refs, **remote_tail;
+static struct ref *remote_refs;
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);
}
}
/* 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;
diff --git a/remote.c b/remote.c
index d66e2f3c93dc72a7112ce101278ae937cc914320..9feb8f4f13791ae0711968ef038f079b159cd528 100644 (file)
--- a/remote.c
+++ b/remote.c
return NULL;
}
+static struct ref **tail_ref(struct ref **head)
+{
+ struct ref **tail = head;
+ while (*tail)
+ tail = &((*tail)->next);
+ return tail;
+}
+
/*
* Note. This is used only by "push"; refspec matching rules for
* push and fetch are subtly different, so do not try to reuse it
* without thinking.
*/
-int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
+int match_refs(struct ref *src, struct ref **dst,
int nr_refspec, const char **refspec, int flags)
{
struct refspec *rs;
int send_mirror = flags & MATCH_REFS_MIRROR;
int errs;
static const char *default_refspec[] = { ":", 0 };
+ struct ref **dst_tail = tail_ref(dst);
if (!nr_refspec) {
nr_refspec = 1;
refspec = default_refspec;
}
rs = parse_push_refspec(nr_refspec, (const char **) refspec);
- errs = match_explicit_refs(src, dst, dst_tail, rs, nr_refspec);
+ errs = match_explicit_refs(src, *dst, &dst_tail, rs, nr_refspec);
/* pick the remainder */
for ( ; src; src = src->next) {
dst_side, &dst_name))
die("Didn't think it matches any more");
}
- dst_peer = find_ref_by_name(dst, dst_name);
+ dst_peer = find_ref_by_name(*dst, dst_name);
if (dst_peer) {
if (dst_peer->peer_ref)
/* We're already sending something to this ref. */
goto free_name;
/* Create a new one and link it */
- dst_peer = make_linked_ref(dst_name, dst_tail);
+ dst_peer = make_linked_ref(dst_name, &dst_tail);
hashcpy(dst_peer->new_sha1, src->new_sha1);
}
dst_peer->peer_ref = copy_ref(src);
diff --git a/remote.h b/remote.h
index 99706a89bc6011c01fcd661d8bad4b26f59b0ca7..257a55538f3ff2d6330b84436a40d6ef972025a0 100644 (file)
--- a/remote.h
+++ b/remote.h
int valid_fetch_refspec(const char *refspec);
struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
-int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
+int match_refs(struct ref *src, struct ref **dst,
int nr_refspec, const char **refspec, int all);
/*
diff --git a/transport.c b/transport.c
index efecb65258ba95ee743f0e3ca178e74e2756e7d1..2f5786d38b8d95078530749182b905e137299ff7 100644 (file)
--- a/transport.c
+++ b/transport.c
if (transport->push_refs) {
struct ref *remote_refs =
transport->get_refs_list(transport, 1);
- struct ref **remote_tail;
struct ref *local_refs = get_local_heads();
int match_flags = MATCH_REFS_NONE;
int verbose = flags & TRANSPORT_PUSH_VERBOSE;
if (flags & TRANSPORT_PUSH_MIRROR)
match_flags |= MATCH_REFS_MIRROR;
- remote_tail = &remote_refs;
- while (*remote_tail)
- remote_tail = &((*remote_tail)->next);
- if (match_refs(local_refs, remote_refs, &remote_tail,
+ if (match_refs(local_refs, &remote_refs,
refspec_nr, refspec, match_flags)) {
return -1;
}