Skip to content

Commit 00a5b79

Browse files
committed
Merge branch 'jc/graduate-remote-hg-bzr' (early part)
* 'jc/graduate-remote-hg-bzr' (early part): remote-helpers: point at their upstream repositories contrib: remote-helpers: add move warnings (v2.0) Revert "Merge branch 'fc/transport-helper-sync-error-fix'"
2 parents df43b41 + 896ba14 commit 00a5b79

File tree

6 files changed

+62
-71
lines changed

6 files changed

+62
-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

contrib/remote-helpers/README

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The remote-helper bridges to access data stored in Mercurial and
2+
Bazaar are maintained outside the git.git tree in the repositories
3+
of its primary author:
4+
5+
https://github.com/felipec/git-remote-hg (for Mercurial)
6+
https://github.com/felipec/git-remote-bzr (for Bazaar)
7+
8+
You can pick a directory on your $PATH and download them from these
9+
repositories, e.g.:
10+
11+
$ wget -O $HOME/bin/git-remote-hg \
12+
https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg
13+
$ wget -O $HOME/bin/git-remote-bzr \
14+
https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr
15+
$ chmod +x $HOME/bin/git-remote-hg $HOME/bin/git-remote-bzr
16+
17+
As a convenience, copies of the last-bundled version of these two
18+
remote-helper bridges are still kept here, but they may become
19+
stale over time.

contrib/remote-helpers/git-remote-bzr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ import re
4343
import StringIO
4444
import atexit, shutil, hashlib, urlparse, subprocess
4545

46+
sys.stderr.write('WARNING: git-remote-bzr is now maintained independently.\n')
47+
sys.stderr.write('WARNING: For more information visit https://github.com/felipec/git-remote-bzr\n')
48+
4649
NAME_RE = re.compile('^([^<>]+)')
4750
AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
4851
EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')

contrib/remote-helpers/git-remote-hg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import atexit
2525
import urlparse, hashlib
2626
import time as ptime
2727

28+
sys.stderr.write('WARNING: git-remote-hg is now maintained independently.\n')
29+
sys.stderr.write('WARNING: For more information visit https://github.com/felipec/git-remote-hg\n')
30+
2831
#
2932
# If you want to see Mercurial revisions as Git commit notes:
3033
# git config core.notesRef refs/notes/hg

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)