git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 12/15] Pass extra (rev-list) args on, at least in some cases

From
Elijah Newren <newren@gmail.com>
Date
Sep 5, 2010, 00:14 UTC
Message-ID
<1283645647-1891-13-git-send-email-newren@gmail.com>
In-Reply-To
<1283645647-1891-1-git-send-email-newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/archive.c    |    2 +-
 builtin/clone.c      |    2 +-
 builtin/fetch-pack.c |    3 ++-
 builtin/send-pack.c  |    3 ++-
 cache.h              |    2 +-
 connect.c            |    9 ++++++++-
 transport-helper.c   |    5 ++++-
 transport.c          |   13 +++++++++----
 transport.h          |    8 +++++---
 9 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/builtin/archive.c b/builtin/archive.c
index 6a887f5..018d2b6 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -35,7 +35,7 @@ static int run_remote_archiver(int argc, const char **argv,
 	if (!_remote->url[0])
 		die("git archive: Remote with no URL");
 	transport = transport_get(_remote, _remote->url[0]);
-	transport_connect(transport, "git-upload-archive", exec, fd);
+	transport_connect(transport, "git-upload-archive", exec, NULL, fd);
 
 	for (i = 1; i < argc; i++)
 		packet_write(fd[1], "argument %s\n", argv[i]);
diff --git a/builtin/clone.c b/builtin/clone.c
index de0fb66..5c0f594 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -545,7 +545,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			int ret;
 
 			sq_quote_argv(&buf, &argv[rest_argc], 0);
-			ret = transport_set_option(transport, TRANS_OPT_SPARSE,
+			ret = transport_set_option(transport, TRANS_OPT_REVLIST_ARGS,
 						   strbuf_detach(&buf, NULL));
 			if (ret)
 				warning ("Sparse clone not supported!\n");
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index dbd8b7b..e550f3d 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -875,7 +875,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 		fd[0] = 0;
 		fd[1] = 1;
 	} else {
-		conn = git_connect(fd, (char *)dest, args.uploadpack,
+		error("Should pass extra_args to git_connect!");
+		conn = git_connect(fd, (char *)dest, args.uploadpack, NULL,
 				   args.verbose ? CONNECT_VERBOSE : 0);
 	}
 
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 481602d..c3ae328 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -478,7 +478,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 		fd[0] = 0;
 		fd[1] = 1;
 	} else {
-		conn = git_connect(fd, dest, receivepack,
+		error("Should pass extra_args to git_connect!");
+		conn = git_connect(fd, dest, receivepack, NULL,
 			args.verbose ? CONNECT_VERBOSE : 0);
 	}
 
diff --git a/cache.h b/cache.h
index 6f88dbb..84c0969 100644
--- a/cache.h
+++ b/cache.h
@@ -937,7 +937,7 @@ extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
 
 #define CONNECT_VERBOSE       (1u << 0)
 extern char *git_getpass(const char *prompt);
-extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
+extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, const char *extra_args, int flags);
 extern int finish_connect(struct child_process *conn);
 extern int path_match(const char *path, int nr, char **match);
 struct extra_have_objects {
diff --git a/connect.c b/connect.c
index 3450cab..42135c8 100644
--- a/connect.c
+++ b/connect.c
@@ -449,7 +449,8 @@ static struct child_process no_fork;
  * the connection failed).
  */
 struct child_process *git_connect(int fd[2], const char *url_orig,
-				  const char *prog, int flags)
+				  const char *prog, const char *extra_args,
+				  int flags)
 {
 	char *url;
 	char *host, *path;
@@ -550,6 +551,8 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 		 * Note: Do not add any other headers here!  Doing so
 		 * will cause older git-daemon servers to crash.
 		 */
+		if (extra_args)
+			error("What to do with extra_args?!?\n");
 		packet_write(fd[1],
 			     "%s %s%chost=%s%c",
 			     prog, path, 0,
@@ -567,6 +570,10 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 	strbuf_addstr(&cmd, prog);
 	strbuf_addch(&cmd, ' ');
 	sq_quote_buf(&cmd, path);
+	if (extra_args) {
+		strbuf_addch(&cmd, ' ');
+		strbuf_addstr(&cmd, extra_args);
+	}
 	if (cmd.len >= MAX_CMD_LEN)
 		die("command line too long");
 
diff --git a/transport-helper.c b/transport-helper.c
index af81fe1..c2b6db3 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -509,7 +509,7 @@ static int process_connect(struct transport *transport,
 }
 
 static int connect_helper(struct transport *transport, const char *name,
-		   const char *exec, int fd[2])
+			  const char *exec, const char *extra_args, int fd[2])
 {
 	struct helper_data *data = transport->data;
 
@@ -518,6 +518,9 @@ static int connect_helper(struct transport *transport, const char *name,
 	if (!data->connect)
 		die("Operation not supported by protocol.");
 
+	if (extra_args)
+		die("extra_args not handled!!!!  OH NOES!!!");
+
 	if (!process_connect_service(transport, name, exec))
 		die("Can't connect to subservice %s.", name);
 
diff --git a/transport.c b/transport.c
index 4dba6f8..1d3cab3 100644
--- a/transport.c
+++ b/transport.c
@@ -475,6 +475,9 @@ static int set_git_option(struct git_transport_options *opts,
 		else
 			opts->depth = atoi(value);
 		return 0;
+	} else if (!strcmp(name, TRANS_OPT_REVLIST_ARGS)) {
+		opts->revlist_args = value;
+		return 0;
 	}
 	return 1;
 }
@@ -489,6 +492,7 @@ static int connect_setup(struct transport *transport, int for_push, int verbose)
 	data->conn = git_connect(data->fd, transport->url,
 				 for_push ? data->options.receivepack :
 				 data->options.uploadpack,
+				 data->options.revlist_args,
 				 verbose ? CONNECT_VERBOSE : 0);
 
 	return 0;
@@ -805,11 +809,12 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
 }
 
 static int connect_git(struct transport *transport, const char *name,
-		       const char *executable, int fd[2])
+		       const char *executable, const char *extra_args,
+		       int fd[2])
 {
 	struct git_transport_data *data = transport->data;
 	data->conn = git_connect(data->fd, transport->url,
-				 executable, 0);
+				 executable, extra_args, 0);
 	fd[0] = data->fd[0];
 	fd[1] = data->fd[1];
 	return 0;
@@ -1124,10 +1129,10 @@ void transport_unlock_pack(struct transport *transport)
 }
 
 int transport_connect(struct transport *transport, const char *name,
-		      const char *exec, int fd[2])
+		      const char *exec, const char *extra_args, int fd[2])
 {
 	if (transport->connect)
-		return transport->connect(transport, name, exec, fd);
+		return transport->connect(transport, name, exec, extra_args, fd);
 	else
 		die("Operation not supported by protocol");
 }
diff --git a/transport.h b/transport.h
index 41e347a..2669e84 100644
--- a/transport.h
+++ b/transport.h
@@ -11,6 +11,7 @@ struct git_transport_options {
 	int depth;
 	const char *uploadpack;
 	const char *receivepack;
+	const char *revlist_args;
 };
 
 struct transport {
@@ -71,7 +72,8 @@ struct transport {
 	int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
 	int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);
 	int (*connect)(struct transport *connection, const char *name,
-		       const char *executable, int fd[2]);
+		       const char *executable, const char *extra_args,
+		       int fd[2]);
 
 	/** get_refs_list(), fetch(), and push_refs() can keep
 	 * resources (such as a connection) reserved for futher
@@ -128,7 +130,7 @@ struct transport *transport_get(struct remote *, const char *);
 #define TRANS_OPT_FOLLOWTAGS "followtags"
 
 /* Fetch only certain paths */
-#define TRANS_OPT_SPARSE "sparse"
+#define TRANS_OPT_REVLIST_ARGS "revlist_args"
 
 /**
  * Returns 0 if the option was used, non-zero otherwise. Prints a
@@ -153,7 +155,7 @@ void transport_take_over(struct transport *transport,
 			 struct child_process *child);
 
 int transport_connect(struct transport *transport, const char *name,
-		      const char *exec, int fd[2]);
+		      const char *exec, const char *extra_args, int fd[2]);
 
 /* Transport methods defined outside transport.c */
 int transport_helper_init(struct transport *transport, const char *name);
-- 
1.7.2.2.140.gd06af
Previous: Elijah NewrenNext: Elijah Newren
Message 38 of 41 in “Sparse clones”
  1. 00/15 Sparse clonesElijah Newren, Sep 5, 2010
  2. 01/15 README-sparse-clone: Add a basic writeup of my ideas for sparse clonesElijah Newren, Sep 5, 2010
  3. Nguyen Thai Ngoc DuySep 5, 2010
  4. Elijah NewrenSep 5, 2010
  5. Nguyen Thai Ngoc DuySep 6, 2010
  6. 02/15 Add tests for client handling in a sparse repositoryElijah Newren, Sep 5, 2010
  7. 03/15 Read sparse limiting args from $GIT_DIR/sparse-limitElijah Newren, Sep 5, 2010
  8. 04/15 When unpacking in a sparse repository, avoid traversing missing trees/blobsElijah Newren, Sep 5, 2010
  9. 05/15 read_tree_recursive: Avoid missing blobs and trees in a sparse repositoryElijah Newren, Sep 5, 2010
  10. Nguyen Thai Ngoc DuySep 5, 2010
  11. Elijah NewrenSep 5, 2010
  12. Elijah NewrenSep 5, 2010
  13. 06/15 Automatically reuse sparse limiting arguments in revision walkingElijah Newren, Sep 5, 2010
  14. Nguyen Thai Ngoc DuySep 5, 2010
  15. Elijah NewrenSep 5, 2010
  16. Nguyen Thai Ngoc DuySep 5, 2010
  17. 07/15 cache_tree_update(): Capability to handle tree entries missing from indexElijah Newren, Sep 5, 2010
  18. Nguyen Thai Ngoc DuySep 5, 2010
  19. Elijah NewrenSep 5, 2010
  20. Elijah NewrenSep 6, 2010
  21. Nguyen Thai Ngoc DuySep 6, 2010
  22. 0/4 en/object-list-with-pathspec updateNguyễn Thái Ngọc Duy, Sep 6, 2010
  23. 1/4 Add testcases showing how pathspecs are ignored with rev-list --objectsNguyễn Thái Ngọc Duy, Sep 6, 2010
  24. 2/4 tree-walk: copy tree_entry_interesting() as is from tree-diff.cNguyễn Thái Ngọc Duy, Sep 6, 2010
  25. Elijah NewrenSep 6, 2010
  26. Nguyen Thai Ngoc DuySep 6, 2010
  27. 3/4 tree-walk: actually move tree_entry_interesting() to tree-walk.cNguyễn Thái Ngọc Duy, Sep 6, 2010
  28. Elijah NewrenSep 6, 2010
  29. Nguyen Thai Ngoc DuySep 6, 2010
  30. Junio C HamanoSep 6, 2010
  31. 4/4 Make rev-list --objects work together with pathspecsNguyễn Thái Ngọc Duy, Sep 6, 2010
  32. Nguyen Thai Ngoc DuySep 7, 2010
  33. Elijah NewrenSep 7, 2010
  34. 08/15 cache_tree_update(): Require relevant tree to be passedElijah Newren, Sep 5, 2010
  35. 09/15 Add tests for communication dealing with sparse repositoriesElijah Newren, Sep 5, 2010
  36. 10/15 sparse-repo: Provide a function to record sparse limiting argumentsElijah Newren, Sep 5, 2010
  37. 11/15 builtin-clone: Accept paths for sparse cloneElijah Newren, Sep 5, 2010
  38. 12/15 Pass extra (rev-list) args on, at least in some casesElijah Newren, Sep 5, 2010
  39. 13/15 upload-pack: Handle extra rev-list arguments being passedElijah Newren, Sep 5, 2010
  40. 14/15 EVIL COMMIT: Include all commitsElijah Newren, Sep 5, 2010
  41. 15/15 clone: Ensure sparse limiting arguments are used in subsequent operationsElijah Newren, Sep 5, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.