Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 10e1fee

Browse files
committed
Revert "Merge branch 'fc/transport-helper-sync-error-fix'"
This reverts commit d508e4a, reversing changes made to e425521. 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 <[email protected]>
1 parent b28aeab commit 10e1fee

File tree

3 files changed

+37
-71
lines changed

3 files changed

+37
-71
lines changed

Documentation/RelNotes/2.0.0.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ UI, Workflows & Features
8888
* "git grep" learned to behave in a way similar to native grep when
8989
"-h" (no header) and "-c" (count) options are given.
9090

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-
9591
* The "simple" mode is the default for "git push".
9692

9793
* "git add -u" and "git add -A", when run without any pathspec, is a

t/t5801-remote-helpers.sh

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -212,42 +212,27 @@ test_expect_success 'push update refs failure' '
212212
echo "update fail" >>file &&
213213
git commit -a -m "update fail" &&
214214
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 &&
217218
git rev-parse --verify testgit/origin/heads/update >actual &&
218219
test_cmp expect actual
219220
)
220221
'
221222

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-
236223
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 &&
239228
cat error &&
240229
grep -q "Error while running fast-import" error
241230
)
242231
'
243232

244233
test_expect_success 'proper failure checks for pushing' '
245234
(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
251236
)
252237
'
253238

transport-helper.c

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
5858
if (strbuf_getline(buffer, helper, '\n') == EOF) {
5959
if (debug)
6060
fprintf(stderr, "Debug: Remote helper quit.\n");
61-
return 1;
61+
exit(128);
6262
}
6363

6464
if (debug)
@@ -71,6 +71,12 @@ static int recvline(struct helper_data *helper, struct strbuf *buffer)
7171
return recvline_fh(helper->out, buffer, helper->name);
7272
}
7373

74+
static void xchgline(struct helper_data *helper, struct strbuf *buffer)
75+
{
76+
sendline(helper, buffer);
77+
recvline(helper, buffer);
78+
}
79+
7480
static void write_constant(int fd, const char *str)
7581
{
7682
if (debug)
@@ -157,8 +163,7 @@ static struct child_process *get_helper(struct transport *transport)
157163
while (1) {
158164
const char *capname;
159165
int mandatory = 0;
160-
if (recvline(data, &buf))
161-
exit(128);
166+
recvline(data, &buf);
162167

163168
if (!*buf.buf)
164169
break;
@@ -195,9 +200,15 @@ static struct child_process *get_helper(struct transport *transport)
195200
} else if (!strcmp(capname, "signed-tags")) {
196201
data->signed_tags = 1;
197202
} 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);
199207
} 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);
201212
} else if (starts_with(capname, "no-private-update")) {
202213
data->no_private_update = 1;
203214
} else if (mandatory) {
@@ -296,9 +307,7 @@ static int set_helper_option(struct transport *transport,
296307
quote_c_style(value, &buf, NULL, 0);
297308
strbuf_addch(&buf, '\n');
298309

299-
sendline(data, &buf);
300-
if (recvline(data, &buf))
301-
exit(128);
310+
xchgline(data, &buf);
302311

303312
if (!strcmp(buf.buf, "ok"))
304313
ret = 0;
@@ -370,8 +379,7 @@ static int fetch_with_fetch(struct transport *transport,
370379
sendline(data, &buf);
371380

372381
while (1) {
373-
if (recvline(data, &buf))
374-
exit(128);
382+
recvline(data, &buf);
375383

376384
if (starts_with(buf.buf, "lock ")) {
377385
const char *name = buf.buf + 5;
@@ -422,8 +430,6 @@ static int get_exporter(struct transport *transport,
422430
struct helper_data *data = transport->data;
423431
struct child_process *helper = get_helper(transport);
424432
int argc = 0, i;
425-
struct strbuf tmp = STRBUF_INIT;
426-
427433
memset(fastexport, 0, sizeof(*fastexport));
428434

429435
/* we need to duplicate helper->in because we want to use it after
@@ -434,14 +440,10 @@ static int get_exporter(struct transport *transport,
434440
fastexport->argv[argc++] = "--use-done-feature";
435441
fastexport->argv[argc++] = data->signed_tags ?
436442
"--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;
445447

446448
for (i = 0; i < revlist_args->nr; i++)
447449
fastexport->argv[argc++] = revlist_args->items[i].string;
@@ -561,9 +563,7 @@ static int process_connect_service(struct transport *transport,
561563
goto exit;
562564

563565
sendline(data, &cmdbuf);
564-
if (recvline_fh(input, &cmdbuf, name))
565-
exit(128);
566-
566+
recvline_fh(input, &cmdbuf, name);
567567
if (!strcmp(cmdbuf.buf, "")) {
568568
data->no_disconnect_req = 1;
569569
if (debug)
@@ -739,22 +739,16 @@ static int push_update_ref_status(struct strbuf *buf,
739739
return !(status == REF_STATUS_OK);
740740
}
741741

742-
static int push_update_refs_status(struct helper_data *data,
742+
static void push_update_refs_status(struct helper_data *data,
743743
struct ref *remote_refs,
744744
int flags)
745745
{
746746
struct strbuf buf = STRBUF_INIT;
747747
struct ref *ref = remote_refs;
748-
int ret = 0;
749-
750748
for (;;) {
751749
char *private;
752750

753-
if (recvline(data, &buf)) {
754-
ret = 1;
755-
break;
756-
}
757-
751+
recvline(data, &buf);
758752
if (!buf.len)
759753
break;
760754

@@ -772,7 +766,6 @@ static int push_update_refs_status(struct helper_data *data,
772766
free(private);
773767
}
774768
strbuf_release(&buf);
775-
return ret;
776769
}
777770

778771
static int push_refs_with_push(struct transport *transport,
@@ -853,7 +846,8 @@ static int push_refs_with_push(struct transport *transport,
853846
sendline(data, &buf);
854847
strbuf_release(&buf);
855848

856-
return push_update_refs_status(data, remote_refs, flags);
849+
push_update_refs_status(data, remote_refs, flags);
850+
return 0;
857851
}
858852

859853
static int push_refs_with_export(struct transport *transport,
@@ -911,15 +905,7 @@ static int push_refs_with_export(struct transport *transport,
911905

912906
if (finish_command(&exporter))
913907
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);
923909
return 0;
924910
}
925911

@@ -988,8 +974,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
988974

989975
while (1) {
990976
char *eov, *eon;
991-
if (recvline(data, &buf))
992-
exit(128);
977+
recvline(data, &buf);
993978

994979
if (!*buf.buf)
995980
break;

0 commit comments

Comments
 (0)