▼ |  | Net: Networking Libraries

1 | HTTP Client
2 | URLs and HTTP
3 | URI Codec: Encoding and Decoding URIs
4 | FTP: Client
5 | Send URL: Opening a Web Browser
6 | SMTP: Sending E-Mail
7 | sendmail: Sending E-Mail
8 | Headers: Parsing and Constructing
9 | Header Field Encoding
10 | IMAP: Reading Mail
11 | POP3: Reading Mail
12 | MIME: Decoding Internet Data
13 | Base 64: Encoding and Decoding
14 | Quoted-Printable: Encoding and Decoding
15 | DNS: Domain Name Service Queries
16 | NNTP: Newsgroup Protocol
17 | TCP: Unit and Signature
18 | TCP Redirect: tcp^ via Channels
19 | SSL Unit: tcp^ via SSL
20 | CGI Scripts
21 | Cookie: Legacy HTTP Client Storage
22 | Git Repository Checkout
| Bibliography
| Index

On this page:

git-checkout
current-git-username
current-git-password
exn: fail: git

top ← prev up next →

### 22`` Git Repository Checkout

(require net/git-checkout) | package: base

The net/git-checkout library provides support for extracting a directory tree from a Git repository that is hosted by a server that implements the git:// protocol or its layering over HTTP(S). The net/git-checkout library does not rely on external binaries (such as a git client) or Git-specific native libraries (such as "libgit").

When run as a program, net/git-checkout accepts command-line arguments to drive the checkout. Use
racket -l- net/git-checkout -h
for information on command-line arguments and flags.

> > procedure
> > (git-checkout |  | hostname |  |  |  |
> > |  | repository |  |  |  |
> > |  | #:dest-dir dest-dir |  |  |  |
> > | [ | #:ref ref |  |  |  |
> > |  | #:transport transport |  |  |  |
> > |  | #:depth depth |  |  |  |
> > |  | #:status-printf status-printf |  |  |  |
> > |  | #:initial-error initial-error |  |  |  |
> > |  | #:tmp-dir given-tmp-dir |  |  |  |
> > |  | #:clean-tmp-dir? clean-tmp-dir? |  |  |  |
> > |  | #:verify-server? verify-server? |  |  |  |
> > |  | #:port port |  |  |  |
> > |  | #:strict-links? strict-links? |  |  |  |
> > |  | #:username username |  |  |  |
> > |  | #:password password]) |  | → |  | string?
> hostname : string?
> repository : string?
> dest-dir : (or/c path-string? #f)
> ref : string? = "master"
> transport : (or/c 'git 'http 'https) = 'git
> depth : (or/c #f exact-positive-integer?) = 1
> | status-printf |  | : |  | (string? any/c ... . -> . void?)
> |  |  | = |  |
> (lambda args
> (apply printf args)
> (flush-output))
> initial-error : (or #f (-> any)) = #f
> given-tmp-dir : (or/c #f path-string?) = #f
> clean-tmp-dir? : any/c = (not given-tmp-dir)
> verify-server? : any/c = #t
> | port |  | : |  | (or/c #f (integer-in 1 65535)) |  | = |  |
> (case transport
> [(git) 9418]
> [(http) 80]
> [(https) 443])
> strict-links? : any/c = #f
> username : (or/c string? #f) = (current-git-username)
> password : (or/c string? #f) = (current-git-password)

Contacts the server at hostname and port (where #f is replaced by the default) to download the repository whose name on the server is repository (normally ending in ".git"). The tree within the repository that is identified by ref (which can be a branch, tag, commit ID, or tree ID) is extracted to dest-dir, and the result id an ID corresponding to ref.

If transport is 'git, then the server is contacted using Git’s native transport. If transport is 'http or 'https, then the server is contacted using HTTP(S). In the case of 'https, the server’s identity is verified unless verify-server? is false or the GIT_SSL_NO_VERIFY environment variable is set.

If dest-dir is #f, then the result is an ID determined for ref from just the server’s report of the available branches and tags, or ref itself if it does not match a branch or tag name and looks like an ID.

A local clone of the repository is not preserved, but is instead discarded after the tree is extracted to dest-dir. If dest-dir does not exist, it is created. If dest-dir does exist, its existing content is left in place except as replaced by content from the Git repository.

If ref identifies a branch or tag by either name or by commit ID, then the git:// protocol allows git-checkout to download only the commits and objects relevant to the branch or tag. Furthermore, the default depth argument allows git-checkout to obtain only the latest commit and its objects, instead of the entire history of the branch or commit. If ref is any other commit ID or tree ID, then the entire repository is downloaded, including all branches.

Status information is reported via status-printf. The same information is always logged with the name 'git-checkout at the 'info level.

If initial-error is not #f, then it is called (to raise an exception or otherwise escape) if initial communication with the server fails to match the expected protocol—perhaps indicating that the server does not provide a Git repository at the given address. If initial-error is #f or returns when called, an exception is raised.

If tmp-dir is not #f, then it is used to store a temporary clone of the repository, and the files are preserved unless clean-tmp-dir? is true. The clone does not currently match the shape that is recognized by other tools, such as git, and so a preserved temporary directory is useful mainly for debugging.

If strict-links? is true, then the checkout fails with an error if it would produce a symbolic link that refers to an absolute path or to a relative path that contains up-directory elements.

If both username and password are non-#f and transport is 'http or 'https, then the provided credentials are passed to the remote server using HTTP Basic Authentication.

Added in version 6.1.1.1 of package base. Changed in version 6.2.900.17: Added the strict-links? argument. Changed in version 6.3: Added the initial-error argument. Changed in version 6.6.0.5: Added the username and password arguments. Changed in version 6.6.0.5: Changed to raise exn:fail:git exceptions instead of exn:fail.

> parameter (current-git-username) → (or/c string? #f)
> (current-git-username username) → void?
> username : (or/c string? #f)
> parameter (current-git-password) → (or/c string? #f)
> (current-git-password password) → void?
> password : (or/c string? #f)

Parameters used by git-checkout as the default values of the username and password arguments to control authentication with the remote server.

Added in version 6.6.0.5 of package base.

> > struct
> > (struct |  | exn:fail:git exn:fail ()
> #:extra-constructor-name make-exn:fail:git
> #:transparent)

Raised by git-checkout due to errors parsing or communicating with the git protocol.

Added in version 6.6.0.5 of package base.

top ← prev up next →