Thread (33 messages) flat view 33 messages, 3 authors, 2016-06-15
DORMANTno replies

Revision v2 of 2 in this series.

Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 08/13] Write local refs written by the "import" helper command only once

From: Sverre Rabbelier <hidden>
Date: 2016-06-15 22:47:40
Subsystem: the rest · Maintainer: Linus Torvalds

At clone time the "import" helper command has already written a
packfile with all refs, so write_remote_refs will create a duplicate
entry for each ref returned by wanted_peer_refs. Prevent this
duplication by setting fetched_refs_written in the transport when
executing the "import" helper command and only adding the extra refs
if it is not set.

Signed-off-by: Sverre Rabbelier <redacted>
---

	I am not 100% sure this is the proper fix, but I do know that
	without this I get a .git/packed-refs file that has duplicate
	entries in it.

 builtin-clone.c    |    5 ++++-
 transport-helper.c |    3 +++
 transport.h        |    2 ++
 3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index 5df8b0f..e44347e 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -542,7 +542,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	if (refs) {
 		clear_extra_refs();
 
-		write_remote_refs(mapped_refs);
+		if(transport->fetched_refs_written)
+			pack_refs(PACK_REFS_ALL);
+		else
+			write_remote_refs(mapped_refs);
 
 		remote_head = find_ref_by_name(refs, "HEAD");
 		remote_head_points_at =
diff --git a/transport-helper.c b/transport-helper.c
index 82caaae..148496c 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -165,7 +165,10 @@ static int fetch(struct transport *transport,
 		return fetch_with_fetch(transport, nr_heads, to_fetch);
 
 	if (data->import)
+	{
+		transport->fetched_refs_written = 1;
 		return fetch_with_import(transport, nr_heads, to_fetch);
+	}
 
 	return -1;
 }
diff --git a/transport.h b/transport.h
index 503db11..7458b9e 100644
--- a/transport.h
+++ b/transport.h
@@ -65,6 +65,8 @@ struct transport {
 	signed verbose : 2;
 	/* Force progress even if the output is not a tty */
 	unsigned progress : 1;
+	/* Refs fetched by transport_get_remote_refs are already written */
+	unsigned fetched_refs_written : 1;
 };
 
 #define TRANSPORT_PUSH_ALL 1
-- 
1.6.5.2.295.g0d105
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help