-
-
Notifications
You must be signed in to change notification settings - Fork 957
-
In command line, I can do git diff master..branch
and also git diff master...branch
. However, in gitPython, it seems the commit.diff(commit2)
is only doing two dot diff. And I couldn't find a way to do three dot diff directly (I have searched through the document and googled around).
I am thinking to find the commit where we branch off, and then do a two way diff - this would be the same as the three way diff of two branches. But it does not work exactly as expected:
# this commit is not the root commit, but the child of the root commit...
commit = list(repo.iter_commits('origin/master..HEAD'))[-1]
diff = commit.diff(repo.head.commit)
Would you have any recommendation?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
I believe I have worked around in following way:
def three_dot_diff_with_master(repo):
# might be slow when the commit tree is very big
master_commits = repo.iter_commits('origin/master')
local_commits = set(repo.iter_commits('HEAD'))
for commit in master_commits :
if commit in local_commits:
break
diffs = commit.diff(repo.head.commit)
I believe this issue can now be closed. But I'll leave the decision to the project admin.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions
-
The above seems like a custom implementation of git merge-base
, which could probably be called with repo.git.merge_base(...)
to do the same but much more swiftly.
Maybe that helps alleviating the need for triple-dot syntax.
Beta Was this translation helpful? Give feedback.