net/git-checkout: support the smart HTTP(S) transport

Git-based hosting services most commonly support the smart HTTPS
protocol, which carries "git://"-format payload in a fairly straightforward
way. (Supporting the dumb protocol looks much more difficult.)

original commit: bbf154ba36
This commit is contained in:
Matthew Flatt 2014-10-15 09:12:09 -06:00
parent dc696a2385
commit 643fcd20e1

View File

@ -6,10 +6,11 @@
@defmodule[net/git-checkout]{The @racketmodname[net/git-checkout] @defmodule[net/git-checkout]{The @racketmodname[net/git-checkout]
library provides support for extracting a directory tree from a Git library provides support for extracting a directory tree from a Git
repository that is hosted by a server that implements @tt{git://} repository that is hosted by a server that implements the @tt{git://}
protocol. The @racketmodname[net/git-checkout] library does not rely protocol or the ``smart'' protocol over HTTP(S). The
on external binaries (such as a @exec{git} client) or native libraries @racketmodname[net/git-checkout] library does not rely on external
(such as @filepath{libgit}).} binaries (such as a @exec{git} client) or Git-specific native
libraries (such as @filepath{libgit}).}
When run as a program, @racket[net/git-checkout] accepts command-line When run as a program, @racket[net/git-checkout] accepts command-line
arguments to drive the checkout. Use arguments to drive the checkout. Use
@ -22,20 +23,29 @@ for information on command-line arguments and flags.
[repository string?] [repository string?]
[#:dest-dir dest-dir path-string?] [#:dest-dir dest-dir path-string?]
[#:ref ref string? "master"] [#:ref ref string? "master"]
[#:transport transport (or/c 'git 'http 'https) 'git]
[#:depth depth (or/c #f positive-exact-integer?) 1] [#:depth depth (or/c #f positive-exact-integer?) 1]
[#:quiet? quiet? any/c #f] [#:quiet? quiet? any/c #f]
[#:tmp-dir given-tmp-dir (or/c #f path-string?) #f] [#:tmp-dir given-tmp-dir (or/c #f path-string?) #f]
[#:clean-tmp-dir? clean-tmp-dir? any/c (not given-tmp-dir)] [#:clean-tmp-dir? clean-tmp-dir? any/c (not given-tmp-dir)]
[#:port port (integer-in 1 65535) 9418]) [#:port port (integer-in 1 65535) (case transport
[(git) 9418]
[(http) 80]
[(https) 443])])
void?]{ void?]{
Contacts the @tt{git://} server at @racket[hostname] and @racket[port] Contacts the server at @racket[hostname] and @racket[port]
to download the repository whose name on the server is to download the repository whose name on the server is
@racket[repository] (normally ending in @filepath{.git}). The tree @racket[repository] (normally ending in @filepath{.git}). The tree
within the repository that is identified by @racket[ref] (which can be within the repository that is identified by @racket[ref] (which can be
a branch, tag, commit ID, or tree ID) is extracted to a branch, tag, commit ID, or tree ID) is extracted to
@racket[dest-dir]. @racket[dest-dir].
If @racket[transport] is @racket['git], then the server is contacted
using Git's native transport. If @racket[transport] is
@racket['http] or @racket['https], then the server is contacted using
HTTP(S) and the ``smart'' Git protocol.
A local clone of the repository is @emph{not} preserved, but is A local clone of the repository is @emph{not} preserved, but is
instead discarded after the tree is extracted to @racket[dest-dir]. instead discarded after the tree is extracted to @racket[dest-dir].
If @racket[dest-dir] does not exist, it is created. If If @racket[dest-dir] does not exist, it is created. If