@@ -566,10 +566,11 @@ def rename(self, new_path, force=False):
566
566
return self
567
567
568
568
@classmethod
569
- def _iter_items (cls , repo , common_path = None ):
569
+ def _iter_items (cls , repo , common_path = None , with_destination = False ):
570
570
if common_path is None :
571
571
common_path = cls ._common_path_default
572
572
rela_paths = set ()
573
+ rela_paths_dest = {}
573
574
574
575
# walk loose refs
575
576
# Currently we do not follow links
@@ -584,21 +585,31 @@ def _iter_items(cls, repo, common_path=None):
584
585
if f == 'packed-refs' :
585
586
continue
586
587
abs_path = to_native_path_linux (join_path (root , f ))
587
- rela_paths .add (abs_path .replace (to_native_path_linux (repo .git_dir ) + '/' , "" ))
588
+ rela_path = abs_path .replace (to_native_path_linux (repo .git_dir ) + '/' , "" )
589
+ rela_paths .add (rela_path )
590
+ if with_destination :
591
+ with open (abs_path , 'r' ) as fp :
592
+ dest = fp .read ().strip ('\n ' )
593
+ rela_paths_dest [rela_path ] = dest
588
594
# END for each file in root directory
589
595
# END for each directory to walk
590
596
591
597
# read packed refs
592
- for sha , rela_path in cls ._iter_packed_refs (repo ): # @UnusedVariable
598
+ for dest , rela_path in cls ._iter_packed_refs (repo ): # @UnusedVariable
593
599
if rela_path .startswith (common_path ):
594
600
rela_paths .add (rela_path )
601
+ if with_destination and rela_path not in rela_paths_dest :
602
+ rela_paths_dest [rela_path ] = dest
595
603
# END relative path matches common path
596
604
# END packed refs reading
597
605
598
606
# return paths in sorted order
599
607
for path in sorted (rela_paths ):
600
608
try :
601
- yield cls .from_path (repo , path )
609
+ if with_destination :
610
+ yield cls .from_path (repo , path ), rela_paths_dest [path ] if path in rela_paths_dest else None
611
+ else :
612
+ yield cls .from_path (repo , path )
602
613
except ValueError :
603
614
continue
604
615
# END for each sorted relative refpath
0 commit comments