Get tripple dot diff with gitpython

Viewed 72

I am getting the diff between two commits using gitpython in below way:

def get_inbetween_commit_diff(repo_path, commit_a, commit_b):
    repo = Repo(repo_path)
    uni_diff_text = repo.git.diff(
        "{}".format(commit_a), "{}".format(commit_b), ignore_blank_lines=True, ignore_space_at_eol=True
    )
    return uni_diff_text

However, the default repo.git.diff shows the diff with double dot. Is there a way to achieve triple dot diff using gitpython? Reference on double dot and triple dot diff: https://matthew-brett.github.io/pydagogue/git_diff_dots.html

1 Answers

repo.git.diff calls git directly, so I think you can just do this:

repo.git.diff(
    "{}...{}".format(commit_a, commit_b), ignore_blank_lines=True, ignore_space_at_eol=True
)
Related