Revert "Merge branch 'fc/transport-helper-sync-error-fix'"

This reverts commit d508e4a8e2391ae2596403b6478d01cf3d5f928f, reversing changes made to e42552135a2a396f37053a89f44952ea907870b2. The author of the original topic says he broke the upcoming 2.0 release with something that relates to "synchronization crash regression" while refusing to give further specifics, so this would unfortunately be the safest option for the upcoming release. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 14, 2014 at 12:06 UTC 10e1feebb454d99eb6644cc53b94255f40e6fe9c
3 files changed +37 -71
Documentation/RelNotes/2.0.0.txt
-4
@@ -88,10 +88,6 @@ UI, Workflows & Features
88 * "git grep" learned to behave in a way similar to native grep when
89 "-h" (no header) and "-c" (count) options are given.
90
91 - * "git push" via transport-helper interface (e.g. remote-hg) has
92 - been updated to allow forced ref updates in a way similar to the
93 - natively supported transports.
94 -
91 * The "simple" mode is the default for "git push".
92
93 * "git add -u" and "git add -A", when run without any pathspec, is a
t/t5801-remote-helpers.sh
+8 -23
@@ -212,30 +212,19 @@ test_expect_success 'push update refs failure' '
212 echo "update fail" >>file &&
213 git commit -a -m "update fail" &&
214 git rev-parse --verify testgit/origin/heads/update >expect &&
215 - test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
216 - git push origin update &&
215 + GIT_REMOTE_TESTGIT_PUSH_ERROR="non-fast forward" &&
216 + export GIT_REMOTE_TESTGIT_PUSH_ERROR &&
217 + test_expect_code 1 git push origin update &&
218 git rev-parse --verify testgit/origin/heads/update >actual &&
219 test_cmp expect actual
220 )
221 '
222
222 -clean_mark () {
223 - cut -f 2 -d ' ' "$1" |
224 - git cat-file --batch-check |
225 - grep commit |
226 - sort >$(basename "$1")
227 -}
228 -
229 -cmp_marks () {
230 - test_when_finished "rm -rf git.marks testgit.marks" &&
231 - clean_mark ".git/testgit/$1/git.marks" &&
232 - clean_mark ".git/testgit/$1/testgit.marks" &&
233 - test_cmp git.marks testgit.marks
234 -}
235 -
223 test_expect_success 'proper failure checks for fetching' '
237 - (cd local &&
238 - test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error &&
224 + (GIT_REMOTE_TESTGIT_FAILURE=1 &&
225 + export GIT_REMOTE_TESTGIT_FAILURE &&
226 + cd local &&
227 + test_must_fail git fetch 2> error &&
228 cat error &&
229 grep -q "Error while running fast-import" error
230 )
@@ -243,11 +232,7 @@ test_expect_success 'proper failure checks for fetching' '
232
233 test_expect_success 'proper failure checks for pushing' '
234 (cd local &&
246 - git checkout -b crash master &&
247 - echo crash >>file &&
248 - git commit -a -m crash &&
249 - test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all &&
250 - cmp_marks origin
235 + test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all
236 )
237 '
238
transport-helper.c
+29 -44
@@ -58,7 +58,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
58 if (strbuf_getline(buffer, helper, '\n') == EOF) {
59 if (debug)
60 fprintf(stderr, "Debug: Remote helper quit.\n");
61 - return 1;
61 + exit(128);
62 }
63
64 if (debug)
@@ -71,6 +71,12 @@ static int recvline(struct helper_data *helper, struct strbuf *buffer)
71 return recvline_fh(helper->out, buffer, helper->name);
72 }
73
74 +static void xchgline(struct helper_data *helper, struct strbuf *buffer)
75 +{
76 + sendline(helper, buffer);
77 + recvline(helper, buffer);
78 +}
79 +
80 static void write_constant(int fd, const char *str)
81 {
82 if (debug)
@@ -157,8 +163,7 @@ static struct child_process *get_helper(struct transport *transport)
163 while (1) {
164 const char *capname;
165 int mandatory = 0;
160 - if (recvline(data, &buf))
161 - exit(128);
166 + recvline(data, &buf);
167
168 if (!*buf.buf)
169 break;
@@ -195,9 +200,15 @@ static struct child_process *get_helper(struct transport *transport)
200 } else if (!strcmp(capname, "signed-tags")) {
201 data->signed_tags = 1;
202 } else if (starts_with(capname, "export-marks ")) {
198 - data->export_marks = xstrdup(capname + strlen("export-marks "));
203 + struct strbuf arg = STRBUF_INIT;
204 + strbuf_addstr(&arg, "--export-marks=");
205 + strbuf_addstr(&arg, capname + strlen("export-marks "));
206 + data->export_marks = strbuf_detach(&arg, NULL);
207 } else if (starts_with(capname, "import-marks")) {
200 - data->import_marks = xstrdup(capname + strlen("import-marks "));
208 + struct strbuf arg = STRBUF_INIT;
209 + strbuf_addstr(&arg, "--import-marks=");
210 + strbuf_addstr(&arg, capname + strlen("import-marks "));
211 + data->import_marks = strbuf_detach(&arg, NULL);
212 } else if (starts_with(capname, "no-private-update")) {
213 data->no_private_update = 1;
214 } else if (mandatory) {
@@ -296,9 +307,7 @@ static int set_helper_option(struct transport *transport,
307 quote_c_style(value, &buf, NULL, 0);
308 strbuf_addch(&buf, '\n');
309
299 - sendline(data, &buf);
300 - if (recvline(data, &buf))
301 - exit(128);
310 + xchgline(data, &buf);
311
312 if (!strcmp(buf.buf, "ok"))
313 ret = 0;
@@ -370,8 +379,7 @@ static int fetch_with_fetch(struct transport *transport,
379 sendline(data, &buf);
380
381 while (1) {
373 - if (recvline(data, &buf))
374 - exit(128);
382 + recvline(data, &buf);
383
384 if (starts_with(buf.buf, "lock ")) {
385 const char *name = buf.buf + 5;
@@ -422,8 +430,6 @@ static int get_exporter(struct transport *transport,
430 struct helper_data *data = transport->data;
431 struct child_process *helper = get_helper(transport);
432 int argc = 0, i;
425 - struct strbuf tmp = STRBUF_INIT;
426 -
433 memset(fastexport, 0, sizeof(*fastexport));
434
435 /* we need to duplicate helper->in because we want to use it after
@@ -434,14 +440,10 @@ static int get_exporter(struct transport *transport,
440 fastexport->argv[argc++] = "--use-done-feature";
441 fastexport->argv[argc++] = data->signed_tags ?
442 "--signed-tags=verbatim" : "--signed-tags=warn-strip";
437 - if (data->export_marks) {
438 - strbuf_addf(&tmp, "--export-marks=%s.tmp", data->export_marks);
439 - fastexport->argv[argc++] = strbuf_detach(&tmp, NULL);
440 - }
441 - if (data->import_marks) {
442 - strbuf_addf(&tmp, "--import-marks=%s", data->import_marks);
443 - fastexport->argv[argc++] = strbuf_detach(&tmp, NULL);
444 - }
443 + if (data->export_marks)
444 + fastexport->argv[argc++] = data->export_marks;
445 + if (data->import_marks)
446 + fastexport->argv[argc++] = data->import_marks;
447
448 for (i = 0; i < revlist_args->nr; i++)
449 fastexport->argv[argc++] = revlist_args->items[i].string;
@@ -561,9 +563,7 @@ static int process_connect_service(struct transport *transport,
563 goto exit;
564
565 sendline(data, &cmdbuf);
564 - if (recvline_fh(input, &cmdbuf, name))
565 - exit(128);
566 -
566 + recvline_fh(input, &cmdbuf, name);
567 if (!strcmp(cmdbuf.buf, "")) {
568 data->no_disconnect_req = 1;
569 if (debug)
@@ -739,22 +739,16 @@ static int push_update_ref_status(struct strbuf *buf,
739 return !(status == REF_STATUS_OK);
740 }
741
742 -static int push_update_refs_status(struct helper_data *data,
742 +static void push_update_refs_status(struct helper_data *data,
743 struct ref *remote_refs,
744 int flags)
745 {
746 struct strbuf buf = STRBUF_INIT;
747 struct ref *ref = remote_refs;
748 - int ret = 0;
749 -
748 for (;;) {
749 char *private;
750
753 - if (recvline(data, &buf)) {
754 - ret = 1;
755 - break;
756 - }
757 -
751 + recvline(data, &buf);
752 if (!buf.len)
753 break;
754
@@ -772,7 +766,6 @@ static int push_update_refs_status(struct helper_data *data,
766 free(private);
767 }
768 strbuf_release(&buf);
775 - return ret;
769 }
770
771 static int push_refs_with_push(struct transport *transport,
@@ -853,7 +846,8 @@ static int push_refs_with_push(struct transport *transport,
846 sendline(data, &buf);
847 strbuf_release(&buf);
848
856 - return push_update_refs_status(data, remote_refs, flags);
849 + push_update_refs_status(data, remote_refs, flags);
850 + return 0;
851 }
852
853 static int push_refs_with_export(struct transport *transport,
@@ -911,15 +905,7 @@ static int push_refs_with_export(struct transport *transport,
905
906 if (finish_command(&exporter))
907 die("Error while running fast-export");
914 - if (push_update_refs_status(data, remote_refs, flags))
915 - return 1;
916 -
917 - if (data->export_marks) {
918 - strbuf_addf(&buf, "%s.tmp", data->export_marks);
919 - rename(buf.buf, data->export_marks);
920 - strbuf_release(&buf);
921 - }
922 -
908 + push_update_refs_status(data, remote_refs, flags);
909 return 0;
910 }
911
@@ -988,8 +974,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
974
975 while (1) {
976 char *eov, *eon;
991 - if (recvline(data, &buf))
992 - exit(128);
977 + recvline(data, &buf);
978
979 if (!*buf.buf)
980 break;