module documentation
Diff functionality with separate codepaths.
This module provides three main functions for different diff scenarios:
- diff_index_to_tree: Shows staged changes (index vs commit) Used by: git diff --staged, git diff --cached
- diff_working_tree_to_tree: Shows all changes from a commit to working tree Used by: git diff <commit>
- diff_working_tree_to_index: Shows unstaged changes (working tree vs index) Used by: git diff (with no arguments)
- Example usage:
from dulwich.repo import Repo from dulwich.diff import diff_index_to_tree import sys
repo = Repo('.') # Show staged changes diff_index_to_tree(repo, sys.stdout.buffer)
# Show changes in specific paths only diff_index_to_tree(repo, sys.stdout.buffer, paths=[b'src/', b'README.md'])
| Class | |
Stream wrapper that colorizes diff output line by line using Rich. |
| Function | diff |
Show staged changes (index vs commit). |
| Function | diff |
Compare working tree to index. |
| Function | diff |
Compare working tree to a specific commit. |
| Function | should |
Check if a path should be included based on path filters. |
| Variable | logger |
Undocumented |
def diff_index_to_tree(repo:
Repo, outstream: BinaryIO, commit_sha: ObjectID | None = None, paths: Sequence[ bytes] | None = None, diff_algorithm: str | None = None):
¶
Show staged changes (index vs commit).
| Parameters | |
repo:Repo | Repository object |
outstream:BinaryIO | Stream to write diff to |
commitObjectID | None | SHA of commit to compare against, or None for HEAD |
paths:Sequence[ | Optional list of paths to filter (as bytes) |
diffstr | None | Algorithm to use for diffing ("myers" or "patience"), defaults to DEFAULT_DIFF_ALGORITHM if None |
def diff_working_tree_to_tree(repo:
Repo, outstream: BinaryIO, commit_sha: ObjectID, paths: Sequence[ bytes] | None = None, diff_algorithm: str | None = None):
¶
Compare working tree to a specific commit.
| Parameters | |
repo:Repo | Repository object |
outstream:BinaryIO | Stream to write diff to |
commitObjectID | SHA of commit to compare against |
paths:Sequence[ | Optional list of paths to filter (as bytes) |
diffstr | None | Algorithm to use for diffing ("myers" or "patience"), defaults to DEFAULT_DIFF_ALGORITHM if None |