| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 64ec0b1 commit 29041f2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -185,6 +185,7 @@ def diff( | |||
| 185 | 185 | other: Union[DiffConstants, "Tree", "Commit", str, None] = INDEX, | |
| 186 | 186 | paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None, | |
| 187 | 187 | create_patch: bool = False, | |
| 188 | + lines_of_context: int = 3, | ||
| 188 | 189 | **kwargs: Any, | |
| 189 | 190 | ) -> "DiffIndex": | |
| 190 | 191 | """Create diffs between two items being trees, trees and index or an index and | |
@@ -214,6 +215,10 @@ def diff( | |||
| 214 | 215 | applied makes the self to other. Patches are somewhat costly as blobs have | |
| 215 | 216 | to be read and diffed. | |
| 216 | 217 | ||
| 218 | + :param line_of_context: | ||
| 219 | + Default 3. Specify the lines of context before and after each change | ||
| 220 | + introduced in the patch. This cooresponds to the -U flag for git diff. | ||
| 221 | + | ||
| 217 | 222 | :param kwargs: | |
| 218 | 223 | Additional arguments passed to :manpage:`git-diff(1)`, such as ``R=True`` to | |
| 219 | 224 | swap both sides of the diff. | |
@@ -241,6 +246,9 @@ def diff( | |||
| 241 | 246 | args.append("--raw") | |
| 242 | 247 | args.append("-z") | |
| 243 | 248 | ||
| 249 | + if lines_of_context: | ||
| 250 | + args.append(f"-U{lines_of_context}") | ||
| 251 | + | ||
| 244 | 252 | # Ensure we never see colored output. | |
| 245 | 253 | # Fixes: https://github.com/gitpython-developers/GitPython/issues/172 | |
| 246 | 254 | args.append("--no-color") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments