Client side support for the Git protocol.
The Dulwich client supports the following capabilities:
- thin-pack
- multi_ack_detailed
- multi_ack
- side-band-64k
- ofs-delta
- quiet
- report-status
- delete-refs
- shallow
Known capabilities that are not supported:
- no-progress
- include-tag
| Class | |
Abstract base class for HTTP Git Clients. |
| Class | |
Pool manager wrapper that handles authentication callbacks. |
| Class | |
Git Client that reads from a bundle file. |
| Class | |
Protocol for determine_wants functions. |
| Class | |
Result of a fetch-pack operation. |
| Class | |
Protocol for generate_pack_data functions. |
| Class | |
Git smart server client. |
| Class | |
Protocol for HTTP response objects (matches urllib3.response.HTTPResponse). |
| Class | |
Git Client that just uses a local on-disk repository. |
| Class | |
Result of a ls-remote operation. |
| Class | |
Wrapper that reports progress during pack data reception. |
| Class | |
SSH vendor that shells out to the local 'plink' command. |
| Class | |
Handle status as reported by servers with 'report-status' capability. |
| Class | |
Result of a upload-pack operation. |
| Class | |
Git client that connects over SSH. |
| Class | |
A client side SSH implementation. |
| Class | |
Git client that talks to a server using a subprocess. |
| Class | |
SSH vendor that shells out to the local 'ssh' command. |
| Class | |
A socket-like object that talks to a subprocess via pipes. |
| Class | |
A Git Client that works over TCP directly (i.e. git://). |
| Class | |
Traditional Git client. |
| Class | |
HTTP Git client using urllib3. |
| Exception | |
Raised when proxy authentication fails. |
| Exception | |
Raised when authentication fails. |
| Exception | |
Invalid wants. |
| Exception | |
Refusing to connect to strange SSH hostname. |
| Function | apply |
Apply bundles from a bundle URI to a repository. |
| Function | build |
Build fetch command packet list for protocol v2 (before delimiter). |
| Function | build |
Build ls-refs command packet lists for protocol v2. |
| Function | check |
Check if proxy should be bypassed for the given URL. |
| Function | check |
Check that a set of wants is valid. |
| Function | default |
Return urllib3 connection pool manager. |
| Function | default |
Return the default user agent string for Dulwich. |
| Function | extract |
Extract object format from server capabilities. |
| Function | find |
Find a capability with a specific key and value. |
| Function | find |
Find command to run for system Git (usually C Git). |
| Function | get |
Read credentials from a Git credential store. |
| Function | get |
Obtain a git client from a URL. |
| Function | get |
Obtain a git client from a URL. |
| Function | negotiate |
Negotiate protocol version with the server. |
| Function | parse |
Parse a rsync-style URL. |
| Function | read |
Read references using protocol version 1. |
| Function | read |
Read references using protocol version 2. |
| Function | read |
Read server capabilities from packet sequence. |
| Constant | COMMON |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | RECEIVE |
Undocumented |
| Constant | UPLOAD |
Undocumented |
| Variable | logger |
Undocumented |
| Class | _ |
Base class for result objects that provide deprecated dict-like interface. |
| Class | _v1 |
No class docstring; 0/4 instance variable, 1/3 method documented |
| Function | _download |
Download a packfile from a URI and verify its hash. |
| Function | _extract |
Extract symrefs and agent from capabilities. |
| Function | _fileno |
Check if a file descriptor is readable. |
| Function | _get |
Undocumented |
| Function | _handle |
Handle the head of a 'git-upload-pack' request. |
| Function | _handle |
Handle the tail of a 'git-upload-pack' request. |
| Function | _read |
Undocumented |
| Function | _read |
Read per-channel data. |
| Function | _remote |
Undocumented |
| Function | _to |
Convert a dict[Ref, ObjectID] to dict[Ref, Optional[ObjectID]]. |
| Function | _urlmatch |
Yield http config sections matching the given URL, ordered by specificity. |
| Function | _win32 |
Wrapper around PeekNamedPipe to check how many bytes are available. |
| Function | _win32 |
Convert a file: URL to a path. |
| Function | _wrap |
Undocumented |
BaseRepo, uri: str, filter_spec: str | None = None, stored_creation_token: int | None = None, progress: Callable[ [ bytes], None] | None = None) -> tuple[ int | None, dict[ bytes, bytes]]:
¶
Apply bundles from a bundle URI to a repository.
This function fetches bundles from the given URI and applies them to the repository, potentially speeding up subsequent fetches.
| Parameters | |
repo:BaseRepo | The target repository to apply bundles to |
uri:str | The bundle URI to fetch from |
filterstr | None | Object filter to match (e.g., "blob:none") |
storedint | None | Previously stored creation token to skip bundles that have already been applied |
progress:Callable[ | Optional callback for progress reporting |
| Returns | |
A tuple of (creation_token, refs) where |
|
| Raises | |
BundleURIError | If fetching or applying bundles fails |
set[ bytes], object_format: str | None, ref_prefix: Sequence[ bytes] | None = None) -> tuple[ list[ bytes], list[ bytes]]:
¶
Build ls-refs command packet lists for protocol v2.
| Parameters | |
serverset[ | Capabilities advertised by the server |
objectstr | None | Object format to use (e.g., "sha1", "sha256"), or None |
refSequence[ | List of ref prefixes to request, or None for default |
| Returns | |
tuple[ | Tuple of (command packets before delimiter, argument packets after delimiter) |
Config | None, pool_manager_cls: type | None = None, proxy_manager_cls: type | None = None, base_url: str | None = None, timeout: float | None = None, cert_reqs: str | None = None, auth_callback: Callable[ [ str, str, int], dict[ str, str] | None] | None = None, proxy_auth_callback: Callable[ [ str, str, int], dict[ str, str] | None] | None = None) -> urllib3.ProxyManager | urllib3.PoolManager | AuthCallbackPoolManager:
¶
Return urllib3 connection pool manager.
Honour detected proxy configurations.
| Parameters | |
config:Config | None | dulwich.config.ConfigDict instance with Git configuration. |
pooltype | None | Pool manager class to use |
proxytype | None | Proxy manager class to use |
basestr | None | Base URL for proxy bypass checks |
timeout:float | None | Timeout for HTTP requests in seconds |
certstr | None | SSL certificate requirements (e.g. "CERT_REQUIRED", "CERT_NONE") |
authCallable[ | Optional callback for HTTP authentication |
proxyCallable[ | Optional callback for proxy authentication |
| Returns | |
urllib3.ProxyManager | urllib3.PoolManager | AuthCallbackPoolManager | Either pool_manager_cls (defaults to urllib3.ProxyManager) instance for proxy configurations, proxy_manager_cls (defaults to urllib3.PoolManager) instance otherwise. If auth callbacks are provided, returns an AuthCallbackPoolManager wrapper. |
Iterable[ bytes], key: bytes, value: bytes | None) -> bytes | None:
¶
Find a capability with a specific key and value.
str, hostname: str, username: str | None = None, fnames: list[ str] = DEFAULT_GIT_CREDENTIALS_PATHS) -> Iterator[ tuple[ str, str]]:
¶
Read credentials from a Git credential store.
str, config: Config | None = None, operation: str | None = None, thin_packs: bool = True, report_activity: Callable[ [ int, str], None] | None = None, quiet: bool = False, include_tags: bool = False, username: str | None = None, password: str | None = None, key_filename: str | None = None, ssh_command: str | None = None, pool_manager: urllib3.PoolManager | None = None) -> tuple[ GitClient, str]:
¶
Obtain a git client from a URL.
| Parameters | |
location:str | URL or path (a string) |
config:Config | None | Optional config object |
operation:str | None | Kind of operation that'll be performed; "pull" or "push" |
thinbool | Whether or not thin packs should be retrieved |
reportCallable[ | Optional callback for reporting transport activity |
quiet:bool | Whether to suppress output |
includebool | Send annotated tags when sending the objects they point to |
username:str | None | Optional username for authentication |
password:str | None | Optional password for authentication |
keystr | None | Optional SSH key file |
sshstr | None | Optional custom SSH command |
poolurllib3.PoolManager | None | Optional urllib3 PoolManager for HTTP(S) connections |
| Returns | |
tuple[ | Tuple with client instance and relative path. |
str, config: Config | None = None, operation: str | None = None, thin_packs: bool = True, report_activity: Callable[ [ int, str], None] | None = None, quiet: bool = False, include_tags: bool = False, username: str | None = None, password: str | None = None, key_filename: str | None = None, ssh_command: str | None = None, pool_manager: urllib3.PoolManager | None = None) -> tuple[ GitClient, str]:
¶
Obtain a git client from a URL.
| Parameters | |
url:str | URL to open (a unicode string) |
config:Config | None | Optional config object |
operation:str | None | Kind of operation that'll be performed; "pull" or "push" |
thinbool | Whether or not thin packs should be retrieved |
reportCallable[ | Optional callback for reporting transport activity |
quiet:bool | Whether to suppress output |
includebool | Send annotated tags when sending the objects they point to |
username:str | None | Optional username for authentication |
password:str | None | Optional password for authentication |
keystr | None | Optional SSH key file |
sshstr | None | Optional custom SSH command |
poolurllib3.PoolManager | None | Optional urllib3 PoolManager for HTTP(S) connections |
| Returns | |
tuple[ | Tuple with client instance and relative path. |
Iterable[ bytes]) -> tuple[ dict[ Ref, ObjectID | None], dict[ Ref, Ref], dict[ Ref, ObjectID]]:
¶
Read references using protocol version 2.
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
str, expected_hash: bytes, hash_algo: str, pack_data: Callable[ [ bytes], int], progress: Callable[ [ bytes], None] | None, http_request: Callable[ [ str], tuple[ HTTPResponse, Callable[ [ int], bytes]]]):
¶
Download a packfile from a URI and verify its hash.
This function downloads data, verifies the hash matches expected_hash, and only then writes data to the repository. This prevents corrupted or malicious data from being written.
| Parameters | |
uri:str | URI to download packfile from |
expectedbytes | Expected hash of the packfile |
hashstr | Hash algorithm to use (e.g., 'sha1', 'sha256') |
packCallable[ | Callback to send pack data to |
progress:Callable[ | Optional progress callback |
httpCallable[ | Function to perform HTTP requests |
| Raises | |
GitProtocolError | If URI scheme is not HTTPS, hash doesn't match, or download fails |
str, config: Config | None, operation: str | None, thin_packs: bool = True, report_activity: Callable[ [ int, str], None] | None = None, quiet: bool = False, include_tags: bool = False, username: str | None = None, password: str | None = None, key_filename: str | None = None, ssh_command: str | None = None, pool_manager: urllib3.PoolManager | None = None) -> tuple[ GitClient, str]:
¶
Undocumented
Protocol, capabilities: Iterable[ bytes], graph_walker: GraphWalker, wants: list[ ObjectID], can_read: Callable[ [], bool] | None, depth: int | None, protocol_version: int | None, shallow_since: str | None = None, shallow_exclude: list[ str] | None = None) -> tuple[ set[ ObjectID] | None, set[ ObjectID] | None]:
¶
Handle the head of a 'git-upload-pack' request.
- whether there is extra graph data to read on proto
- depth: Depth for request protocol_version: Neogiated Git protocol version. shallow_since: Deepen the history to include commits after this date shallow_exclude: Deepen the history to exclude commits reachable from these refs
| Parameters | |
proto:Protocol | Protocol object to read from |
capabilities:Iterable[ | List of negotiated capabilities |
graphGraphWalker | GraphWalker instance to call .ack() on |
wants:list[ | List of commits to fetch |
canCallable[ | function that returns a boolean that indicates |
depth:int | None | Undocumented |
protocolint | None | Undocumented |
shallowstr | None | Undocumented |
shallowlist[ | Undocumented |
| Returns | |
tuple[ | Undocumented |
Protocol, capabilities: Set[ bytes], graph_walker: GraphWalker, pack_data: Callable[ [ bytes], int], progress: Callable[ [ bytes], None] | None = None, rbufsize: int = _RBUFSIZE, protocol_version: int = 0, http_request: Callable[ [ str], tuple[ HTTPResponse, Callable[ [ int], bytes]]] | None = None):
¶
Handle the tail of a 'git-upload-pack' request.
| Parameters | |
proto:Protocol | Protocol object to read from |
capabilities:Set[ | List of negotiated capabilities |
graphGraphWalker | GraphWalker instance to call .ack() on |
packCallable[ | Function to call with pack data |
progress:Callable[ | Optional progress reporting function |
rbufsize:int | Read buffer size |
protocolint | Neogiated Git protocol version. |
httpCallable[ | Optional HTTP request function for downloading packfile URIs |
Convert a dict[Ref, ObjectID] to dict[Ref, Optional[ObjectID]].
This is needed for compatibility with result types that expect Optional values.
Yield http config sections matching the given URL, ordered by specificity.
Yields sections from least specific to most specific, so callers can apply settings in order with more specific settings overriding less specific ones.
| Parameters | |
config:Config | Git configuration object |
url:str | None | URL to match against config sections (if None, only yields global http section) |
| Returns | |
Iterator[ | Undocumented |
| Yields | |
| Config section tuples that match the URL, ordered by specificity |