Skip to content

Commit a48cfd9

Browse files
committed
Merge pull request presslabs#225 from promulo/issue-208
Avoid searching branch commits lists twice
2 parents a8daf3f + cae2f82 commit a48cfd9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gitfs/repository.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,19 @@ def find_diverge_commits(self, first_branch, second_branch):
469469
if second_commit.hex == first_commit.hex:
470470
break
471471

472-
if first_commit in second_commits:
472+
try:
473473
index = second_commits.index(first_commit)
474+
except ValueError:
475+
pass
476+
else:
474477
second_commits = second_commits[:index]
475478
common_parent = first_commit
476479

477-
if second_commit in first_commits:
480+
try:
478481
index = first_commits.index(second_commit)
482+
except ValueError:
483+
pass
484+
else:
479485
first_commits = first_commits[:index]
480486
common_parent = second_commit
481487

0 commit comments

Comments
 (0)