@@ -217,19 +217,25 @@ def get_commits_list(cls, path_ifc: str, lookup: dict[str, Any]) -> None:
217217 rev = [props .display_branch ],
218218 )
219219 )
220- commits_relevant = list (
220+ commits_relevant = set (
221221 git .objects .commit .Commit .iter_items (
222222 repo = repo ,
223223 rev = [props .display_branch ],
224224 paths = [path_ifc ],
225225 )
226226 )
227227
228+ def is_relevant (commit ):
229+ if commit in commits_relevant :
230+ return True
231+ # Merge commits are relevant too
232+ return len (commit .parents ) > 1 and any (p in commits_relevant for p in commit .parents )
233+
228234 for commit in commits :
229235
230236 if props .ifcgit_filter == "tagged" and commit .hexsha not in lookup :
231237 continue
232- elif props .ifcgit_filter == "relevant" and commit not in commits_relevant :
238+ elif props .ifcgit_filter == "relevant" and not is_relevant ( commit ) :
233239 continue
234240
235241 props .ifcgit_commits .add ()
@@ -239,7 +245,7 @@ def get_commits_list(cls, path_ifc: str, lookup: dict[str, Any]) -> None:
239245 list_item .author_name = commit .author .name
240246 list_item .author_email = commit .author .email
241247 list_item .committed_date = int (commit .committed_date )
242- if commit in commits_relevant :
248+ if is_relevant ( commit ) :
243249 list_item .relevant = True
244250 if commit .hexsha in lookup :
245251 for tag in lookup [commit .hexsha ]:
@@ -589,7 +595,7 @@ def git_merge(cls, branch_name: str) -> Union[str, None]:
589595 """Attempt a git merge. Returns None on clean merge, 'conflict' on expected
590596 GitCommandError, or 'error' on an unknown GitError."""
591597 repo = IfcGitRepo .repo
592- branch = repo .branches [branch_name ]
598+ branch = repo .refs [branch_name ]
593599 try :
594600 repo .git .merge (branch )
595601 return None
@@ -603,7 +609,7 @@ def git_merge_no_commit(cls, branch_name: str) -> Union[str, None]:
603609 """Attempt a git merge without committing (always leaves a merge state to abort).
604610 Returns None on clean merge, 'conflict' on conflict, or 'error' on unknown failure."""
605611 repo = IfcGitRepo .repo
606- branch = repo .branches [branch_name ]
612+ branch = repo .refs [branch_name ]
607613 try :
608614 repo .git .merge (branch , no_commit = True , no_ff = True )
609615 return None
@@ -619,8 +625,8 @@ def git_mergetool(cls, mergetool: str, path_ifc: str) -> Union[list, None]:
619625 report_path = path_ifc + ".ifcmerge"
620626 try :
621627 repo .git .mergetool (tool = mergetool )
622- except git .exc .GitCommandError :
623- pass
628+ except git .exc .GitCommandError as e :
629+ print ( f"ifcgit: mergetool failed: { e } " )
624630
625631 conflicts = None
626632 if os .path .exists (report_path ):
@@ -636,6 +642,10 @@ def git_mergetool(cls, mergetool: str, path_ifc: str) -> Union[list, None]:
636642 os .remove (report_path )
637643 except OSError :
638644 pass
645+
646+ if conflicts is None and repo .index .unmerged_blobs ():
647+ conflicts = []
648+
639649 return conflicts
640650
641651 @classmethod
0 commit comments