@@ -58,9 +58,9 @@ class ProgressPrinter:
5858
5959 def __post_init__ (self ) -> None :
6060 if not self .enabled :
61- self ._is_tty = False
6261 return
6362 self ._is_tty = bool (getattr (self .tty_stream , "isatty" , lambda : False )())
63+ print (f"[tags] enabled: { self .enabled } ,is_tty: { self ._is_tty } " )
6464
6565 def _render_bar (self , done : int , total : int ) -> str :
6666 if total <= 0 :
@@ -861,8 +861,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
861861 created : Dict [str , int ] = {}
862862 done : Set [str ] = set ()
863863 current_ts : Optional [int ] = None
864- progress = ProgressPrinter (enabled = verbose , prefix = '[git] batch ' )
865- last_filled = - 1
864+ progress = ProgressPrinter (enabled = verbose , prefix = '[git] scan ' )
865+ total_lines = 0
866866
867867 try :
868868 with tempfile .NamedTemporaryFile (prefix = 'git-log-' , suffix = '.txt' , delete = False , mode = 'w' , encoding = 'utf-8' ) as fp :
@@ -888,8 +888,14 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
888888
889889 if out_path is None :
890890 return {}
891+
892+ # Progress: use processed line count / total line count.
893+ # Only compute total_lines when verbose to avoid an extra full pass.
894+ with open (out_path , 'r' , encoding = 'utf-8' , errors = 'replace' ) as f_total :
895+ total_lines = sum (1 for _ in f_total )
896+
891897 with open (out_path , 'r' , encoding = 'utf-8' , errors = 'replace' ) as f :
892- for line in f :
898+ for line_no , line in enumerate ( f , start = 1 ) :
893899 s = line .rstrip ('\n ' )
894900 if not s :
895901 continue
@@ -903,6 +909,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
903909 continue
904910
905911 parts = s .split ('\t ' )
912+ if len (parts ) < 2 :
913+ continue
906914 status = parts [0 ]
907915 # Rename: Rxxx\told\tnew
908916 if status .startswith ('R' ) and len (parts ) >= 3 :
@@ -921,8 +929,7 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
921929 created [final ] = current_ts
922930 continue
923931
924- if len (parts ) < 2 :
925- continue
932+
926933 path = parts [1 ]
927934 if path in interest_paths :
928935 final = path
@@ -933,18 +940,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
933940
934941 updated .setdefault (final , current_ts )
935942 created [final ] = current_ts
936- if status == 'A' :
937- done .add (final )
938- if len (done ) == len (interest_paths ):
939- break
940-
941- filled = 0
942- for k in interest_paths :
943- if k in updated and k in created :
944- filled += 1
945- if filled != last_filled :
946- progress .update (filled , len (interest_paths ))
947- last_filled = filled
943+ # Throttle progress updates to reduce TTY overhead.
944+ progress .update (line_no , total_lines )
948945 finally :
949946 if out_path :
950947 try :
@@ -958,7 +955,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
958955 u = updated .get (k )
959956 if c is not None and u is not None :
960957 result [k ] = (c , u )
961- progress .close (len (interest_paths ))
958+ # Mark progress completed (even if we early-stopped).
959+ progress .close (total_lines )
962960 return result
963961
964962
@@ -1128,8 +1126,8 @@ def process_directory(cfg: ProcessConfig) -> int:
11281126 for i , p in enumerate (files , start = 1 ):
11291127 if process_file (cfg , p ):
11301128 count += 1
1131- if cfg .verbose :
1132- print (f"[ok] { p .relative_to (cfg .target_dir ).as_posix ()} " )
1129+ # if cfg.verbose:
1130+ # print(f"[ok] {p.relative_to(cfg.target_dir).as_posix()}")
11331131 progress .update (i , total )
11341132 progress .close (total )
11351133
0 commit comments