On this page:
git-checkout

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    
  #:tmp-dir given-tmp-dir    
  #:clean-tmp-dir? clean-tmp-dir?    
  #:verify-server? verify-server?    
  #:port port])  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))
  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])
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 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.

Added in version 6.1.1.1 of package base.