Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix(git): Normalize stderr output to prevent instability

Maximilian Roos9fcb9fab3f64
diff --git a/src/git.rs b/src/git.rs
index f5317ec37..b3c739ec2 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -939,11 +939,14 @@ impl Repository {
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
+ // Normalize carriage returns to newlines for consistent output
+ // Git uses \r for progress updates; in non-TTY contexts this causes snapshot instability
+ let stderr = stderr.replace('\r', "\n");
// Log errors with ! prefix
for line in stderr.trim().lines() {
log::debug!(" ! {}", line);
}
- return Err(GitError::CommandFailed(stderr.into_owned()));
+ return Err(GitError::CommandFailed(stderr));
}
let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap
index 46c27d504..3cf090880 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap
@@ -12,10 +12,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpDxsSjV/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpr5RlUa/test-config.toml
---
success: false
exit_code: 1
@@ -25,7 +26,8 @@ exit_code: 1
----- stderr -----
❌ Rebase onto main incomplete
-  Rebasing (1/1) error: could not apply [SHA]... Update shared.txt in feature
+  Rebasing (1/1)
+  error: could not apply [SHA]... Update shared.txt in feature
  hint: Resolve all conflicts manually, mark them as resolved with
  hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
  hint: You can instead skip this commit: run "git rebase --skip".