I want to get the changes to a file in a git repository using the gitpython library.
I'm using
repo.git.diff(commit_a, commit_b, file_path)
for that. But I need to increase the context of the diff similar to the -U
argument. How can I do this using the library?
I solved it using subprocess
at the end, like this:
subprocess.check_output(['git', 'diff', '-U500', commit_a, commit_b, file_path], cwd=project_dir)
.