module documentation

Git smart network protocol server implementation.

For more detailed implementation on the network protocol, see the Documentation/technical directory in the cgit distribution, and in particular:

  • Documentation/technical/protocol-capabilities.txt
  • Documentation/technical/pack-protocol.txt

Currently supported capabilities:

  • include-tag
  • thin-pack
  • multi_ack_detailed
  • multi_ack
  • side-band-64k
  • ofs-delta
  • no-progress
  • report-status
  • delete-refs
  • shallow
  • symref
Class Backend A backend for the Git smart server implementation.
Class BackendRepo Repository abstraction used by the Git server.
Class DictBackend Trivial backend that looks up Git repositories in a dictionary.
Class FileSystemBackend Simple backend looking up Git repositories in the local file system.
Class Handler Smart protocol command handler base class.
Class MultiAckDetailedGraphWalkerImpl Graph walker implementation speaking the multi-ack-detailed protocol.
Class MultiAckGraphWalkerImpl Graph walker implementation that speaks the multi-ack protocol.
Class PackHandler Protocol handler for packs.
Class ReceivePackHandler Protocol handler for downloading a pack from the client.
Class SingleAckGraphWalkerImpl Graph walker implementation that speaks the single-ack protocol.
Class TCPGitRequestHandler Undocumented
Class TCPGitServer Undocumented
Class UploadArchiveHandler Undocumented
Class UploadPackHandler Protocol handler for uploading a pack to the client.
Function generate_info_refs Generate an info refs file.
Function generate_objects_info_packs Generate an index for for packs.
Function main Entry point for starting a TCP git server.
Function serve_command Serve a single command.
Function update_server_info Generate server info for dumb file access.
Constant DEFAULT_HANDLERS Undocumented
Variable logger Undocumented
Class _ProtocolGraphWalker A graph walker that knows the git protocol.
Function _all_wants_satisfied Check whether all the current wants are satisfied by a set of haves.
Function _find_shallow Find shallow commits according to a given depth.
Function _split_proto_line Split a line read from the wire.
Function _want_satisfied Undocumented
Constant _GRAPH_WALKER_COMMANDS Undocumented
def generate_info_refs(repo):

Generate an info refs file.

def generate_objects_info_packs(repo):

Generate an index for for packs.

def main(argv=sys.argv):

Entry point for starting a TCP git server.

def serve_command(handler_cls, argv=sys.argv, backend=None, inf=sys.stdin, outf=sys.stdout):

Serve a single command.

This is mostly useful for the implementation of commands used by e.g. git+ssh.

Returns: Exit code for use with sys.exit. 0 on success, 1 on failure.

handler_clsHandler class to use for the request
argvexecv-style command-line arguments. Defaults to sys.argv.
backendBackend to use
infFile-like object to read from, defaults to standard input.
outfFile-like object to write to, defaults to standard output.
def update_server_info(repo):

Generate server info for dumb file access.

This generates info/refs and objects/info/packs, similar to "git update-server-info".



{b'git-upload-pack': UploadPackHandler,
 b'git-receive-pack': ReceivePackHandler,
 b'git-upload-archive': UploadArchiveHandler}
logger =


def _all_wants_satisfied(store, haves, wants):

Check whether all the current wants are satisfied by a set of haves.

Note: Wants are specified with set_wants rather than passed in since
in the current interface they are determined outside this class.
storeObject store to retrieve objects from
havesA set of commits we know the client has.
wantsA set of commits the client wants
def _find_shallow(store, heads, depth):

Find shallow commits according to a given depth.

Returns: A tuple of (shallow, not_shallow), sets of SHAs that should be
considered shallow and unshallow according to the arguments. Note that these sets may overlap if a commit is reachable along multiple paths.
storeAn ObjectStore for looking up objects.
headsIterable of head SHAs to start walking from.
depthThe depth of ancestors to include. A depth of one includes only the heads themselves.
def _split_proto_line(line, allowed):

Split a line read from the wire.

Returns: a tuple having one of the following forms:
('want', obj_id) ('have', obj_id) ('done', None) (None, None) (for a flush-pkt)
lineThe line read from the wire.
allowedAn iterable of command names that should be allowed. Command names not listed below as possible return values will be ignored. If None, any commands from the possible return values are allowed.
UnexpectedCommandErrorif the line cannot be parsed into one of the allowed return values.
def _want_satisfied(store, haves, want, earliest):