@@ -297,13 +297,26 @@ def draw_head(self, commit, commitId):
297297
298298 def draw_branch (self , commit ):
299299 x = 0
300- branches = [branch .name for branch in self .repo .heads ]
300+
301+ remote_tracking_branches = self .get_remote_tracking_branches ()
302+
303+ branches = [branch .name for branch in self .repo .heads ] + list (
304+ remote_tracking_branches .keys ()
305+ )
306+
301307 for selected_branch in self .selected_branches :
302308 branches .insert (0 , branches .pop (branches .index (selected_branch )))
303309
304310 for branch in branches :
305-
306- if commit .hexsha == self .repo .heads [branch ].commit .hexsha :
311+ # Use forward slash to check if branch is local or remote tracking
312+ # and draw the branch label if its hexsha matches the current commit
313+ if (
314+ "/" not in branch # local branch
315+ and commit .hexsha == self .repo .heads [branch ].commit .hexsha
316+ ) or (
317+ "/" in branch # remote tracking branch
318+ and commit .hexsha == remote_tracking_branches [branch ]
319+ ):
307320 branchText = m .Text (
308321 branch , font = "Monospace" , font_size = 20 , color = self .scene .fontColor
309322 )
@@ -924,6 +937,15 @@ def draw_dark_ref(self):
924937 def trim_path (self , path ):
925938 return (path [:5 ] + "..." + path [- 15 :]) if len (path ) > 20 else path
926939
940+ def get_remote_tracking_branches (self ):
941+ remote_refs = [remote .refs for remote in self .repo .remotes ]
942+ remote_tracking_branches = {}
943+ for reflist in remote_refs :
944+ for ref in reflist :
945+ if "HEAD" not in ref .name and ref .name not in remote_tracking_branches :
946+ remote_tracking_branches [ref .name ] = ref .commit .hexsha
947+ return remote_tracking_branches
948+
927949
928950class DottedLine (m .Line ):
929951 def __init__ (self , * args , dot_spacing = 0.4 , dot_kwargs = {}, ** kwargs ):
0 commit comments