You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is three a way to do three dot diff between two branches? #1426
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)
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
Activity
iwccsbfb commentedon Apr 11, 2022
I believe I have worked around in following way:
I believe this issue can now be closed. But I'll leave the decision to the project admin.
Thank you