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

[RFC PATCH v2 8/8] Support mandatory capabilities

From
ILIlari Liusvaara <ilari.liusvaara@elisanet.fi>
Date
Dec 4, 2009, 15:56 UTC
Message-ID
<1259942168-24869-11-git-send-email-ilari.liusvaara@elisanet.fi>
In-Reply-To
<1259942168-24869-1-git-send-email-ilari.liusvaara@elisanet.fi>

Add support for marking capability as mandatory for hosting git version to understand. This is useful for helpers which require various types of assistance from main git binary.

Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
 Documentation/git-remote-helpers.txt |    5 ++++-
 transport-helper.c                   |   29 ++++++++++++++++++++++-------
 2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-remote-helpers.txt b/Documentation/git-remote-helpers.txt
index 91cd9eb..6af6824 100644
--- a/Documentation/git-remote-helpers.txt
+++ b/Documentation/git-remote-helpers.txt
@@ -25,7 +25,10 @@ Commands are given by the caller on the helper's standard input, one per line.
 
 'capabilities'::
 	Lists the capabilities of the helper, one per line, ending
-	with a blank line.
+	with a blank line. Each capability may be preceeded with '*'.
+	This marks them mandatory for git version using the remote
+	helper to understand (unknown mandatory capability is fatal
+	error).
 
 'list'::
 	Lists the refs, one per line, in the format "<value> <name>
diff --git a/transport-helper.c b/transport-helper.c
index 03920bb..9ddcdc3 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -140,27 +140,42 @@ static struct child_process *get_helper(struct transport *transport)
 	write_constant(helper->in, "capabilities\n");
 
 	while (1) {
+		const char* capname;
+		int mandatory = 0;
 		recvline(data, &buf);
 
 		if (!*buf.buf)
 			break;
-		if(debug) fprintf(stderr, "Debug: Got cap %s\n", buf.buf);
-		if (!strcmp(buf.buf, "fetch"))
+
+		if(*buf.buf == '*') {
+			capname = buf.buf + 1;
+			mandatory = 1;
+		} else
+			capname = buf.buf;
+
+		if(debug) fprintf(stderr, "Debug: Got cap %s\n", capname);
+		if (!strcmp(capname, "fetch"))
 			data->fetch = 1;
-		if (!strcmp(buf.buf, "option"))
+		else if (!strcmp(capname, "option"))
 			data->option = 1;
-		if (!strcmp(buf.buf, "push"))
+		else if (!strcmp(capname, "push"))
 			data->push = 1;
-		if (!strcmp(buf.buf, "import"))
+		else if (!strcmp(capname, "import"))
 			data->import = 1;
-		if (!data->refspecs && !prefixcmp(buf.buf, "refspec ")) {
+		else if (!data->refspecs && !prefixcmp(capname, "refspec ")) {
 			ALLOC_GROW(refspecs,
 				   refspec_nr + 1,
 				   refspec_alloc);
 			refspecs[refspec_nr++] = strdup(buf.buf + strlen("refspec "));
 		}
-		if (!strcmp(buf.buf, "connect"))
+		else if (!strcmp(capname, "connect"))
 			data->connect = 1;
+		else if (mandatory) {
+			fflush(stderr);
+			die("Unknown madatory capability %s. This remote "
+			    "helper probably needs newer version of Git.\n",
+			    capname);
+		}
 	}
 	if (refspecs) {
 		int i;
-- 
1.6.6.rc1.288.g40e67
Previous: Sverre Rabbelier
Message 20 of 20 in “Remote helpers smart transport extensions”
  1. 0/8 Remote helpers smart transport extensionsIlari Liusvaara, Dec 4, 2009
  2. 0/8 Remote helpers smart transport extensionsIlari Liusvaara, Dec 4, 2009
  3. 0/8 Remote helpers smart transport extensionsIlari Liusvaara, Dec 4, 2009
  4. 1/8 Pass unknown protocols to external protocol handlersIlari Liusvaara, Dec 4, 2009
  5. Sverre RabbelierDec 4, 2009
  6. Shawn O. PearceDec 4, 2009
  7. Ilari LiusvaaraDec 5, 2009
  8. 2/8 Refactor git transport options parsingIlari Liusvaara, Dec 4, 2009
  9. 3/8 Support taking over transportsIlari Liusvaara, Dec 4, 2009
  10. Shawn O. PearceDec 4, 2009
  11. Ilari LiusvaaraDec 5, 2009
  12. 4/8 Support remote helpers implementing smart transportsIlari Liusvaara, Dec 4, 2009
  13. Shawn O. PearceDec 4, 2009
  14. Ilari LiusvaaraDec 5, 2009
  15. 5/8 Support remote archive from external protocol helpersIlari Liusvaara, Dec 4, 2009
  16. 6/8 Remove special casing of http, https and ftpIlari Liusvaara, Dec 4, 2009
  17. Sverre RabbelierDec 4, 2009
  18. 7/8 Add remote helper debug modeIlari Liusvaara, Dec 4, 2009
  19. Sverre RabbelierDec 4, 2009
  20. 8/8 Support mandatory capabilitiesIlari Liusvaara, Dec 4, 2009

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.