Support mandatory capabilities
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ilari Liusvaara committed
Dec 9, 2009 at 17:26 UTC
28ed5b3524c1ee5245131691b783d897239f5b03
2 files changed
+23
-7
Documentation/git-remote-helpers.txt
+4
-1
@@ -25,7 +25,10 @@ Commands are given by the caller on the helper's standard input, one per line.
25
26
'capabilities'::
27
Lists the capabilities of the helper, one per line, ending
28
- with a blank line.
28
+ with a blank line. Each capability may be preceeded with '*'.
29
+ This marks them mandatory for git version using the remote
30
+ helper to understand (unknown mandatory capability is fatal
31
+ error).
32
33
'list'::
34
Lists the refs, one per line, in the format "<value> <name>
transport-helper.c
+19
-6
@@ -93,25 +93,38 @@ static struct child_process *get_helper(struct transport *transport)
93
94
data->out = xfdopen(helper->out, "r");
95
while (1) {
96
+ const char *capname;
97
+ int mandatory = 0;
98
recvline(data, &buf);
99
100
if (!*buf.buf)
101
break;
102
+
103
+ if (*buf.buf == '*') {
104
+ capname = buf.buf + 1;
105
+ mandatory = 1;
106
+ } else
107
+ capname = buf.buf;
108
+
109
if (debug)
101
- fprintf(stderr, "Debug: Got cap %s\n", buf.buf);
102
- if (!strcmp(buf.buf, "fetch"))
110
+ fprintf(stderr, "Debug: Got cap %s\n", capname);
111
+ if (!strcmp(capname, "fetch"))
112
data->fetch = 1;
104
- if (!strcmp(buf.buf, "option"))
113
+ else if (!strcmp(capname, "option"))
114
data->option = 1;
106
- if (!strcmp(buf.buf, "push"))
115
+ else if (!strcmp(capname, "push"))
116
data->push = 1;
108
- if (!strcmp(buf.buf, "import"))
117
+ else if (!strcmp(capname, "import"))
118
data->import = 1;
110
- if (!data->refspecs && !prefixcmp(buf.buf, "refspec ")) {
119
+ else if (!data->refspecs && !prefixcmp(capname, "refspec ")) {
120
ALLOC_GROW(refspecs,
121
refspec_nr + 1,
122
refspec_alloc);
123
refspecs[refspec_nr++] = strdup(buf.buf + strlen("refspec "));
124
+ } else if (mandatory) {
125
+ die("Unknown madatory capability %s. This remote "
126
+ "helper probably needs newer version of Git.\n",
127
+ capname);
128
}
129
}
130
if (refspecs) {