[PATCH 8/9] fetch: Don't fetch tags twice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When refspecs are fetched which match tags (e.g.,
+refs/tags/*:refs/tags/<remote>/* or +refs/*:refs/remotes/<remote>/*)
and without --no-tags, we end up fetching the same tags twice because of
the +refs/tags/*:refs/tags/* refspec built into fetch.  Instead, when
processing the built-in refspec, ignore tags which are already mapped.

Signed-off-by: Andreas Gruenbacher <agruen@xxxxxxx>
---
 builtin/fetch.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8728153..8c01876 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -149,6 +149,7 @@ static void add_default_tags(const struct ref *remote_refs,
 			     struct ref *ref_map,
 			     struct ref ***tail)
 {
+	struct string_list mapped_refs = { NULL, 0, 0, 0 };
 	struct ref *tags = NULL, **tags_tail = &tags;
 	struct ref *ref, *peer_ref, **tag;
 
@@ -168,15 +169,19 @@ static void add_default_tags(const struct ref *remote_refs,
 	}
 	sort_string_list(peeled_map);
 
-	for (ref = ref_map; ref; ref = ref->next)
+	for (ref = ref_map; ref; ref = ref->next) {
+		string_list_append(ref->name, &mapped_refs);
 		if (ref->peer_ref)
 			string_list_insert(ref->peer_ref->name, existing_refs);
+	}
+	sort_string_list(&mapped_refs);
 
 	get_fetch_map(remote_refs, tag_refspec, &tags_tail, 0);
 	for (tag = &tags; *tag; ) {
 		ref = *tag;
 		peer_ref = ref->peer_ref;
-		if (!string_list_has_string(existing_refs, peer_ref->name)) {
+		if (!(string_list_has_string(existing_refs, peer_ref->name) ||
+		      string_list_has_string(&mapped_refs, ref->name))) {
 			struct string_list_item *item;
 
 			item = string_list_lookup(ref->name, peeled_map);
@@ -187,6 +192,7 @@ static void add_default_tags(const struct ref *remote_refs,
 		}
 		tag = &(*tag)->next;
 	}
+	string_list_clear(&mapped_refs, 0);
 
 	free_refs(tags);
 }
-- 
1.7.0.2.273.gc2413


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]