aboutsummaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2007-10-08 00:25:07 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-10-15 20:28:06 -0400
commit2467a4fa03ff849fcf2f6a93b89057aebd49c62b (patch)
treefc6ff162d3b6ca5680483f8ef714934aae8e484f /remote.c
parent2b5a06edca8f7237aad6464b349b79772024d2a2 (diff)
downloadgit-2467a4fa03ff849fcf2f6a93b89057aebd49c62b.tar.gz
git-2467a4fa03ff849fcf2f6a93b89057aebd49c62b.tar.xz
Remove duplicate ref matches in fetch
If multiple refspecs matched the same ref, the update would be processed multiple times. Now having the same destination for the same source has no additional effect, and having the same destination for different sources is an error. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/remote.c b/remote.c
index e7d735b98..e2ca4d32b 100644
--- a/remote.c
+++ b/remote.c
@@ -380,6 +380,33 @@ int for_each_remote(each_remote_fn fn, void *priv)
return result;
}
+void ref_remove_duplicates(struct ref *ref_map)
+{
+ struct ref **posn;
+ struct ref *next;
+ for (; ref_map; ref_map = ref_map->next) {
+ if (!ref_map->peer_ref)
+ continue;
+ posn = &ref_map->next;
+ while (*posn) {
+ if ((*posn)->peer_ref &&
+ !strcmp((*posn)->peer_ref->name,
+ ref_map->peer_ref->name)) {
+ if (strcmp((*posn)->name, ref_map->name))
+ die("%s tracks both %s and %s",
+ ref_map->peer_ref->name,
+ (*posn)->name, ref_map->name);
+ next = (*posn)->next;
+ free((*posn)->peer_ref);
+ free(*posn);
+ *posn = next;
+ } else {
+ posn = &(*posn)->next;
+ }
+ }
+ }
+}
+
int remote_has_url(struct remote *remote, const char *url)
{
int i;