transport-helper: add 'signed-tags' capability

This allows a remote helper using the 'export' protocol to specify that it supports signed tags, changing the handing from 'warn-strip' to 'verbatim'. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Keeping committed Apr 14, 2013 at 11:57 UTC 0d957a4df5248b53c4160babdcfa0cefba848c93
4 files changed +21 -2
Documentation/gitremote-helpers.txt
+4
@@ -202,6 +202,10 @@ capability then it should advertise `refspec *:*`.
202 marks specified in <file> before processing any input. For details,
203 read up on '--import-marks=<file>' in linkgit:git-fast-export[1].
204
205 +'signed-tags'::
206 + This modifies the 'export' capability, instructing Git to pass
207 + '--signed-tags=verbatim' to linkgit:git-fast-export[1]. In the
208 + absence of this capability, Git will use '--signed-tags=warn-strip'.
209
210
211
git-remote-testgit
+1
@@ -38,6 +38,7 @@ do
38 echo "*import-marks $gitmarks"
39 echo "*export-marks $gitmarks"
40 fi
41 + test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
42 echo
43 ;;
44 list)
t/t5801-remote-helpers.sh
+11 -1
@@ -173,7 +173,17 @@ test_expect_success GPG 'push signed tag' '
173 git tag -s -m signed-tag signed-tag &&
174 git push origin signed-tag
175 ) &&
176 - compare_refs local signed-tag^{} server signed-tag^{}
176 + compare_refs local signed-tag^{} server signed-tag^{} &&
177 + test_must_fail compare_refs local signed-tag server signed-tag
178 +'
179 +
180 +test_expect_success GPG 'push signed tag with signed-tags capability' '
181 + (cd local &&
182 + git checkout master &&
183 + git tag -s -m signed-tag signed-tag-2 &&
184 + GIT_REMOTE_TESTGIT_SIGNED_TAGS=1 git push origin signed-tag-2
185 + ) &&
186 + compare_refs local signed-tag-2 server signed-tag-2
187 '
188
189 test_done
transport-helper.c
+5 -1
@@ -25,6 +25,7 @@ struct helper_data {
25 option : 1,
26 push : 1,
27 connect : 1,
28 + signed_tags : 1,
29 no_disconnect_req : 1;
30 char *export_marks;
31 char *import_marks;
@@ -191,6 +192,8 @@ static struct child_process *get_helper(struct transport *transport)
192 refspecs[refspec_nr++] = xstrdup(capname + strlen("refspec "));
193 } else if (!strcmp(capname, "connect")) {
194 data->connect = 1;
195 + } else if (!strcmp(capname, "signed-tags")) {
196 + data->signed_tags = 1;
197 } else if (!prefixcmp(capname, "export-marks ")) {
198 struct strbuf arg = STRBUF_INIT;
199 strbuf_addstr(&arg, "--export-marks=");
@@ -413,7 +416,8 @@ static int get_exporter(struct transport *transport,
416 fastexport->argv = xcalloc(6 + revlist_args->nr, sizeof(*fastexport->argv));
417 fastexport->argv[argc++] = "fast-export";
418 fastexport->argv[argc++] = "--use-done-feature";
416 - fastexport->argv[argc++] = "--signed-tags=warn-strip";
419 + fastexport->argv[argc++] = data->signed_tags ?
420 + "--signed-tags=verbatim" : "--signed-tags=warn-strip";
421 if (data->export_marks)
422 fastexport->argv[argc++] = data->export_marks;
423 if (data->import_marks)