Skip to content

Commit cae2f82

Browse files
author
Paulo Romulo
committed
Avoid searching lists twice
1 parent 60c4c69 commit cae2f82

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
@@ -460,13 +460,19 @@ def find_diverge_commits(self, first_branch, second_branch):
460460
if second_commit.hex == first_commit.hex:
461461
break
462462

463-
if first_commit in second_commits:
463+
try:
464464
index = second_commits.index(first_commit)
465+
except ValueError:
466+
pass
467+
else:
465468
second_commits = second_commits[:index]
466469
common_parent = first_commit
467470

468-
if second_commit in first_commits:
471+
try:
469472
index = first_commits.index(second_commit)
473+
except ValueError:
474+
pass
475+
else:
470476
first_commits = first_commits[:index]
471477
common_parent = second_commit
472478

0 commit comments

Comments
 (0)