Skip to content

Commit bd33a29

Browse files
committed
Merge branch 'il/vcs-helper'
* il/vcs-helper: Reset possible helper before reusing remote structure Remove special casing of http, https and ftp Support remote archive from all smart transports Support remote helpers implementing smart transports Support taking over transports Refactor git transport options parsing Pass unknown protocols to external protocol handlers Support mandatory capabilities Add remote helper debug mode Conflicts: Documentation/git-remote-helpers.txt transport-helper.c
2 parents dc96c5e + 27a557a commit bd33a29

File tree

7 files changed

+505
-93
lines changed

7 files changed

+505
-93
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
/git-relink
109109
/git-remote
110110
/git-remote-curl
111+
/git-remote-http
112+
/git-remote-https
113+
/git-remote-ftp
114+
/git-remote-ftps
111115
/git-repack
112116
/git-replace
113117
/git-repo-config

Documentation/git-remote-helpers.txt

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ Commands are given by the caller on the helper's standard input, one per line.
2525

2626
'capabilities'::
2727
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).
2932

3033
'list'::
3134
Lists the refs, one per line, in the format "<value> <name>
@@ -90,6 +93,20 @@ Supported if the helper has the "push" capability.
9093
+
9194
Supported if the helper has the "import" capability.
9295

96+
'connect' <service>::
97+
Connects to given service. Standard input and standard output
98+
of helper are connected to specified service (git prefix is
99+
included in service name so e.g. fetching uses 'git-upload-pack'
100+
as service) on remote side. Valid replies to this command are
101+
empty line (connection established), 'fallback' (no smart
102+
transport support, fall back to dumb transports) and just
103+
exiting with error message printed (can't connect, don't
104+
bother trying to fall back). After line feed terminating the
105+
positive (empty) response, the output of service starts. After
106+
the connection ends, the remote helper exits.
107+
+
108+
Supported if the helper has the "connect" capability.
109+
93110
If a fatal error occurs, the program writes the error message to
94111
stderr and exits. The caller should expect that a suitable error
95112
message has been printed if the child closes the connection without
@@ -123,6 +140,9 @@ CAPABILITIES
123140
all, it must cover all refs reported by the list command; if
124141
it is not used, it is effectively "*:*"
125142

143+
'connect'::
144+
This helper supports the 'connect' command.
145+
126146
REF LIST ATTRIBUTES
127147
-------------------
128148

@@ -165,9 +185,15 @@ OPTIONS
165185
but don't actually change any repository data. For most
166186
helpers this only applies to the 'push', if supported.
167187

188+
'option servpath <c-style-quoted-path>'::
189+
Set service path (--upload-pack, --receive-pack etc.) for
190+
next connect. Remote helper MAY support this option. Remote
191+
helper MUST NOT rely on this option being set before
192+
connect request occurs.
193+
168194
Documentation
169195
-------------
170-
Documentation by Daniel Barkalow.
196+
Documentation by Daniel Barkalow and Ilari Liusvaara
171197

172198
GIT
173199
---

Makefile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,16 @@ BUILT_INS += git-stage$X
424424
BUILT_INS += git-status$X
425425
BUILT_INS += git-whatchanged$X
426426

427+
ifdef NO_CURL
428+
REMOTE_CURL_PRIMARY =
429+
REMOTE_CURL_ALIASES =
430+
REMOTE_CURL_NAMES =
431+
else
432+
REMOTE_CURL_PRIMARY = git-remote-http$X
433+
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
434+
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
435+
endif
436+
427437
# what 'all' will build and 'install' will install in gitexecdir,
428438
# excluding programs for built-in commands
429439
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
@@ -1107,7 +1117,7 @@ else
11071117
else
11081118
CURL_LIBCURL = -lcurl
11091119
endif
1110-
PROGRAMS += git-remote-curl$X git-http-fetch$X
1120+
PROGRAMS += $(REMOTE_CURL_NAMES) git-http-fetch$X
11111121
curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
11121122
ifeq "$(curl_check)" "070908"
11131123
ifndef NO_EXPAT
@@ -1686,7 +1696,13 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
16861696
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
16871697
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
16881698

1689-
git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
1699+
$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
1700+
$(QUIET_LNCP)$(RM) $@ && \
1701+
ln $< $@ 2>/dev/null || \
1702+
ln -s $< $@ 2>/dev/null || \
1703+
cp $< $@
1704+
1705+
$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
16901706
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
16911707
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
16921708

@@ -1877,6 +1893,7 @@ endif
18771893
ifneq (,$X)
18781894
$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
18791895
endif
1896+
18801897
bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
18811898
execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
18821899
{ test "$$bindir/" = "$$execdir/" || \
@@ -1890,6 +1907,12 @@ endif
18901907
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
18911908
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
18921909
done; } && \
1910+
{ for p in $(REMOTE_CURL_ALIASES); do \
1911+
$(RM) "$$execdir/$$p" && \
1912+
ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
1913+
ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
1914+
cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
1915+
done; } && \
18931916
./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
18941917

18951918
install-doc:

builtin-archive.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "cache.h"
66
#include "builtin.h"
77
#include "archive.h"
8+
#include "transport.h"
89
#include "parse-options.h"
910
#include "pkt-line.h"
1011
#include "sideband.h"
@@ -25,12 +26,16 @@ static void create_output_file(const char *output_file)
2526
static int run_remote_archiver(int argc, const char **argv,
2627
const char *remote, const char *exec)
2728
{
28-
char *url, buf[LARGE_PACKET_MAX];
29+
char buf[LARGE_PACKET_MAX];
2930
int fd[2], i, len, rv;
30-
struct child_process *conn;
31+
struct transport *transport;
32+
struct remote *_remote;
3133

32-
url = xstrdup(remote);
33-
conn = git_connect(fd, url, exec, 0);
34+
_remote = remote_get(remote);
35+
if (!_remote->url[0])
36+
die("git archive: Remote with no URL");
37+
transport = transport_get(_remote, _remote->url[0]);
38+
transport_connect(transport, "git-upload-archive", exec, fd);
3439

3540
for (i = 1; i < argc; i++)
3641
packet_write(fd[1], "argument %s\n", argv[i]);
@@ -53,9 +58,7 @@ static int run_remote_archiver(int argc, const char **argv,
5358

5459
/* Now, start reading from fd[0] and spit it out to stdout */
5560
rv = recv_sideband("archive", fd[0], 1);
56-
close(fd[0]);
57-
close(fd[1]);
58-
rv |= finish_connect(conn);
61+
rv |= transport_disconnect(transport);
5962

6063
return !!rv;
6164
}

0 commit comments

Comments
 (0)