@@ -267,8 +267,6 @@ def progress_cb(output, timestamp):
267267 )
268268
269269 all_output : str = ""
270- code = None
271- line = None
272270 if log_in_real_time and callback is None :
273271
274272 def progress_cb (output : t .AnyStr , timestamp : datetime .datetime ) -> None :
@@ -277,34 +275,13 @@ def progress_cb(output: t.AnyStr, timestamp: datetime.datetime) -> None:
277275
278276 callback = progress_cb
279277
280- # Note: When git detects that stderr is not a TTY (e.g., when piped),
281- # it outputs progress with newlines instead of carriage returns.
282- # This causes each progress update to appear on a new line.
283- # To get proper single-line progress updates, git would need to be
284- # connected to a pseudo-TTY, which would require significant changes
285- # to how subprocess execution is handled.
286-
287- timeout_stdout : bytes | None = None
288- timeout_stderr : bytes | None = None
289- if timeout is None :
290- while code is None :
291- code = proc .poll ()
292-
293- if callback and callable (callback ) and proc .stderr is not None :
294- line = console_to_str (proc .stderr .read (128 ))
295- if line :
296- callback (
297- output = line ,
298- timestamp = datetime .datetime .now (tz = datetime .UTC ),
299- )
300- else :
301- code , timeout_stdout , timeout_stderr = _wait_with_deadline (
302- proc ,
303- deadline = time .monotonic () + timeout ,
304- timeout = timeout ,
305- callback = callback ,
306- cmd = _stringify_command (normalized_args ),
307- )
278+ code , timeout_stdout , timeout_stderr = _wait_with_deadline (
279+ proc ,
280+ deadline = time .monotonic () + timeout if timeout is not None else None ,
281+ timeout = timeout ,
282+ callback = callback ,
283+ cmd = _stringify_command (normalized_args ),
284+ )
308285 if callback and callable (callback ):
309286 callback (output = "\r " , timestamp = datetime .datetime .now (tz = datetime .UTC ))
310287
@@ -348,12 +325,12 @@ def progress_cb(output: t.AnyStr, timestamp: datetime.datetime) -> None:
348325def _wait_with_deadline (
349326 proc : subprocess .Popen [bytes ],
350327 * ,
351- deadline : float ,
352- timeout : float ,
328+ deadline : float | None ,
329+ timeout : float | None ,
353330 callback : ProgressCallbackProtocol | None ,
354331 cmd : str | list [str ],
355332) -> tuple [int , bytes | None , bytes | None ]:
356- """Wait for ``proc`` to exit , enforcing a wall-clock deadline.
333+ """Drain child pipes while waiting , enforcing an optional wall-clock deadline.
357334
358335 Drains both ``stdout`` and ``stderr`` concurrently so a child that fills
359336 either kernel pipe buffer (~64 KiB on Linux) cannot deadlock waiting for
@@ -427,8 +404,8 @@ def _wait_with_deadline(
427404 )
428405 break
429406
430- remaining = deadline - time .monotonic ()
431- if remaining <= 0 :
407+ remaining = deadline - time .monotonic () if deadline is not None else None
408+ if remaining is not None and remaining <= 0 :
432409 # ``vcs_exit_code`` deliberately omitted here: ``proc.returncode``
433410 # is still ``None`` because the child has not been signalled yet,
434411 # and CLAUDE.md treats ``vcs_exit_code`` as a scalar ``int``.
@@ -452,12 +429,16 @@ def _wait_with_deadline(
452429 timeout = timeout ,
453430 )
454431
455- wait = min (_TIMEOUT_POLL_INTERVAL_SECONDS , remaining )
432+ wait = (
433+ min (_TIMEOUT_POLL_INTERVAL_SECONDS , remaining )
434+ if remaining is not None
435+ else _TIMEOUT_POLL_INTERVAL_SECONDS
436+ )
456437 if not registered :
457- # No streams to select on (e.g. ``os.set_blocking`` failed on
458- # Windows pipes). Yield the CPU explicitly instead of busy-
459- # looping until the deadline or process exit.
460- time . sleep ( wait )
438+ try :
439+ proc . wait ( timeout = remaining )
440+ except subprocess . TimeoutExpired :
441+ continue
461442 continue
462443
463444 events = sel .select (timeout = wait )
0 commit comments