[RFC PATCH 15/15] clone: Ensure sparse limiting arguments are used in subsequent operations

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

 



After fetching, register sparse args for subsequent checkout portion of
clone, and record sparse args for any later commands run in the clone.

Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---
 builtin/clone.c                            |   17 +++++++++++++----
 t/t5721-sparse-repository-communication.sh |    4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 5c0f594..4f55ab0 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "quote.h"
+#include "sparse-repo.h"
 
 /*
  * Overall FIXMEs:
@@ -370,7 +371,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	const struct ref *refs, *remote_head;
 	const struct ref *remote_head_points_at;
 	const struct ref *our_head_points_at;
-	struct ref *mapped_refs;
+	struct ref *mapped_refs = NULL;
 	struct strbuf key = STRBUF_INIT, value = STRBUF_INIT;
 	struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT;
 	struct transport *transport = NULL;
@@ -519,9 +520,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	strbuf_reset(&value);
 
 	if (is_local) {
+		if (argc > rest_argc)
+			die("Sparse clones of local repositories must be done using the file:// protocol.");
 		refs = clone_local(path, git_dir);
 		mapped_refs = wanted_peer_refs(refs, refspec);
 	} else {
+		struct strbuf quoted_sparse_args = STRBUF_INIT;
 		struct remote *remote = remote_get(option_origin);
 		transport = transport_get(remote, remote->url[0]);
 
@@ -541,12 +545,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 					     option_upload_pack);
 
 		if (argc > rest_argc) {
-			struct strbuf buf = STRBUF_INIT;
 			int ret;
 
-			sq_quote_argv(&buf, &argv[rest_argc], 0);
+			sq_quote_argv(&quoted_sparse_args, &argv[rest_argc], 0);
 			ret = transport_set_option(transport, TRANS_OPT_REVLIST_ARGS,
-						   strbuf_detach(&buf, NULL));
+						   quoted_sparse_args.buf);
 			if (ret)
 				warning ("Sparse clone not supported!\n");
 		}
@@ -556,6 +559,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			mapped_refs = wanted_peer_refs(refs, refspec);
 			transport_fetch_refs(transport, mapped_refs);
 		}
+
+		if (argc > rest_argc) {
+			register_sparse_limits(&argv[rest_argc]);
+			record_sparse_limits(quoted_sparse_args.buf);
+		}
+		strbuf_release(&quoted_sparse_args);
 	}
 
 	if (refs) {
diff --git a/t/t5721-sparse-repository-communication.sh b/t/t5721-sparse-repository-communication.sh
index 35cb6a2..61ce8c6 100755
--- a/t/t5721-sparse-repository-communication.sh
+++ b/t/t5721-sparse-repository-communication.sh
@@ -52,7 +52,7 @@ test_expect_success 'make comparison sparse repository' '
 	)
 '
 
-test_expect_failure 'basic sparse clone succeeds' '
+test_expect_success 'basic sparse clone succeeds' '
 	rm -fr dst &&
 	git clone "file://$(pwd)/src" dst -- sub/b/ &&
 	(
@@ -82,7 +82,7 @@ test_expect_failure 'basic sparse clone succeeds' '
 	)
 '
 
-test_expect_failure 'basic sparse clone guts match expectations' '
+test_expect_success 'basic sparse clone guts match expectations' '
 	(
 		# Loose objects only, to facilitate comparison
 		cd dst &&
-- 
1.7.2.2.140.gd06af

--
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]