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 AckGraphWalkerImpl Base class for acknowledgment graph walker implementations.
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 TCP request handler for git protocol.
Class TCPGitServer TCP server for git protocol.
Class UploadArchiveHandler Handler for git-upload-archive requests.
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 _split_proto_line Split a line read from the wire.
Function _want_satisfied Check if a specific want is satisfied by a set of haves.
Constant _GRAPH_WALKER_COMMANDS Undocumented
def generate_info_refs(repo: BaseRepo) -> Iterator[bytes]:

Generate an info refs file.

def generate_objects_info_packs(repo: BaseRepo) -> Iterator[bytes]:

Generate an index for for packs.

def main(argv: list[str] = sys.argv):

Entry point for starting a TCP git server.

def serve_command(handler_cls: type[Handler], argv: list[str] = sys.argv, backend: Backend | None = None, inf: IO[bytes] | None = None, outf: IO[bytes] | None = None) -> int:

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.

Parameters
handler_cls:type[Handler]Handler class to use for the request
argv:list[str]execv-style command-line arguments. Defaults to sys.argv.
backend:Backend | NoneBackend to use
inf:IO[bytes] | NoneFile-like object to read from, defaults to standard input.
outf:IO[bytes] | NoneFile-like object to write to, defaults to standard output.
Returns
intUndocumented
def update_server_info(repo: BaseRepo):

Generate server info for dumb file access.

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

DEFAULT_HANDLERS =

Undocumented

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

Undocumented

def _all_wants_satisfied(store: ObjectContainer, haves: AbstractSet[ObjectID], wants: set[ObjectID]) -> bool:

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.
Parameters
store:ObjectContainerObject store to retrieve objects from
haves:AbstractSet[ObjectID]A set of commits we know the client has.
wants:set[ObjectID]A set of commits the client wants
Returns
boolUndocumented
def _split_proto_line(line: bytes | None, allowed: Iterable[bytes | None] | None) -> tuple[bytes | None, bytes | int | None]:

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)
Parameters
line:bytes | NoneThe line read from the wire.
allowed:Iterable[bytes | None] | NoneAn 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.
Returns
tuple[bytes | None, bytes | int | None]Undocumented
Raises
UnexpectedCommandErrorif the line cannot be parsed into one of the allowed return values.
def _want_satisfied(store: ObjectContainer, haves: set[ObjectID], want: ObjectID, earliest: int) -> bool:

Check if a specific want is satisfied by a set of haves.

Returns: True if the want is satisfied by the haves

Parameters
store:ObjectContainerObject store to retrieve objects from
haves:set[ObjectID]Set of commit IDs the client has
want:ObjectIDCommit ID the client wants
earliest:intEarliest commit time to consider
Returns
boolUndocumented
_GRAPH_WALKER_COMMANDS =

Undocumented

Value
(COMMAND_HAVE, COMMAND_DONE, None)