Jir Jir - 3 years ago 158
Python Question

Get Commit object by hexsha in git-python

I'm trying to find the content of the commits that have been checked in between two specific commits.

In git I'd do

git rev-list --ancestry-path <older_commit_sha>..<newer_commit_sha>

In git-python, since it doesn't look there's a direct way of doing it, I resorted to calling the exact command, through
The output is a string of commit IDs (hex SHA).

Now, is there a way in git-python to create a valid
object starting from the hex SHA as given by

Jir Jir
Answer Source

After much poking, and given this question is not getting much traction, I resorted to using .execute(). Specifically:

commits = repo.git.execute(['git', 'rev-list', '--ancestry-path',
                            '%s..%s' % (oldCommit.hexsha, newCommit.hexsha)]).split()

Of course, oldCommit and newCommit are git.Commit objects.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download