Skip to content

Commit

Permalink
Merge branch 'il/vcs-helper'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Jan 13, 2010
2 parents dc96c5e + 27a557a commit bd33a29
Show file tree
Hide file tree
Showing 7 changed files with 505 additions and 93 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
/git-relink
/git-remote
/git-remote-curl
/git-remote-http
/git-remote-https
/git-remote-ftp
/git-remote-ftps
/git-repack
/git-replace
/git-repo-config
Expand Down
30 changes: 28 additions & 2 deletions Documentation/git-remote-helpers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ Commands are given by the caller on the helper's standard input, one per line.

'capabilities'::
Lists the capabilities of the helper, one per line, ending
with a blank line.
with a blank line. Each capability may be preceeded with '*'.
This marks them mandatory for git version using the remote
helper to understand (unknown mandatory capability is fatal
error).

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

'connect' <service>::
Connects to given service. Standard input and standard output
of helper are connected to specified service (git prefix is
included in service name so e.g. fetching uses 'git-upload-pack'
as service) on remote side. Valid replies to this command are
empty line (connection established), 'fallback' (no smart
transport support, fall back to dumb transports) and just
exiting with error message printed (can't connect, don't
bother trying to fall back). After line feed terminating the
positive (empty) response, the output of service starts. After
the connection ends, the remote helper exits.
+
Supported if the helper has the "connect" capability.

If a fatal error occurs, the program writes the error message to
stderr and exits. The caller should expect that a suitable error
message has been printed if the child closes the connection without
Expand Down Expand Up @@ -123,6 +140,9 @@ CAPABILITIES
all, it must cover all refs reported by the list command; if
it is not used, it is effectively "*:*"

'connect'::
This helper supports the 'connect' command.

REF LIST ATTRIBUTES
-------------------

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

'option servpath <c-style-quoted-path>'::
Set service path (--upload-pack, --receive-pack etc.) for
next connect. Remote helper MAY support this option. Remote
helper MUST NOT rely on this option being set before
connect request occurs.

Documentation
-------------
Documentation by Daniel Barkalow.
Documentation by Daniel Barkalow and Ilari Liusvaara

GIT
---
Expand Down
27 changes: 25 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ BUILT_INS += git-stage$X
BUILT_INS += git-status$X
BUILT_INS += git-whatchanged$X

ifdef NO_CURL
REMOTE_CURL_PRIMARY =
REMOTE_CURL_ALIASES =
REMOTE_CURL_NAMES =
else
REMOTE_CURL_PRIMARY = git-remote-http$X
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
endif

# what 'all' will build and 'install' will install in gitexecdir,
# excluding programs for built-in commands
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
Expand Down Expand Up @@ -1107,7 +1117,7 @@ else
else
CURL_LIBCURL = -lcurl
endif
PROGRAMS += git-remote-curl$X git-http-fetch$X
PROGRAMS += $(REMOTE_CURL_NAMES) git-http-fetch$X
curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
ifeq "$(curl_check)" "070908"
ifndef NO_EXPAT
Expand Down Expand Up @@ -1686,7 +1696,13 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)

git-remote-curl$X: remote-curl.o http.o http-walker.o $(GITLIBS)
$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
$(QUIET_LNCP)$(RM) $@ && \
ln $< $@ 2>/dev/null || \
ln -s $< $@ 2>/dev/null || \
cp $< $@

$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)

Expand Down Expand Up @@ -1877,6 +1893,7 @@ endif
ifneq (,$X)
$(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';)
endif

bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
{ test "$$bindir/" = "$$execdir/" || \
Expand All @@ -1890,6 +1907,12 @@ endif
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
done; } && \
{ for p in $(REMOTE_CURL_ALIASES); do \
$(RM) "$$execdir/$$p" && \
ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
done; } && \
./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"

install-doc:
Expand Down
17 changes: 10 additions & 7 deletions builtin-archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "cache.h"
#include "builtin.h"
#include "archive.h"
#include "transport.h"
#include "parse-options.h"
#include "pkt-line.h"
#include "sideband.h"
Expand All @@ -25,12 +26,16 @@ static void create_output_file(const char *output_file)
static int run_remote_archiver(int argc, const char **argv,
const char *remote, const char *exec)
{
char *url, buf[LARGE_PACKET_MAX];
char buf[LARGE_PACKET_MAX];
int fd[2], i, len, rv;
struct child_process *conn;
struct transport *transport;
struct remote *_remote;

url = xstrdup(remote);
conn = git_connect(fd, url, exec, 0);
_remote = remote_get(remote);
if (!_remote->url[0])
die("git archive: Remote with no URL");
transport = transport_get(_remote, _remote->url[0]);
transport_connect(transport, "git-upload-archive", exec, fd);

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

/* Now, start reading from fd[0] and spit it out to stdout */
rv = recv_sideband("archive", fd[0], 1);
close(fd[0]);
close(fd[1]);
rv |= finish_connect(conn);
rv |= transport_disconnect(transport);

return !!rv;
}
Expand Down
Loading

0 comments on commit bd33a29

Please sign in to comment.