Skip to content

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

docs: Remove unnecessary newlines in error formatting

Maximilian Roos77bc28ac5d44
diff --git a/CLAUDE.md b/CLAUDE.md
index 139b4ae83..b3807c38f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -376,6 +376,16 @@ super::gutter(format_with_gutter(&error.to_string(), "", None))?; // Adds ❌ e
print!("{}", format_with_gutter(&command));
```
+**Linebreaks with gutter content:** Use a single newline (`\n`) between error messages and gutter content, never double newlines (`\n\n`). The gutter's visual structure (background color, indentation) provides sufficient separation - blank lines are redundant.
+
+```rust
+// ✅ GOOD - single newline before gutter
+format!("{header}\n{}", format_with_gutter(error, "", None))
+
+// ❌ BAD - double newline creates unnecessary blank line
+format!("{header}\n\n{}", format_with_gutter(error, "", None))
+```
+
### Snapshot Testing Requirement
diff --git a/src/git/error.rs b/src/git/error.rs
index 37d671b35..06fdbd76a 100644
--- a/src/git/error.rs
+++ b/src/git/error.rs
@@ -331,7 +331,7 @@ fn format_error_block(header: String, error: &str) -> String {
if trimmed.is_empty() {
header
} else {
- format!("{header}\n\n{}", format_with_gutter(trimmed, "", None))
+ format!("{header}\n{}", format_with_gutter(trimmed, "", None))
}
}
diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rs
index 35a0ade90..81cf06d0d 100644
--- a/src/git/repository/mod.rs
+++ b/src/git/repository/mod.rs
@@ -43,7 +43,7 @@ impl<T, E: std::fmt::Display> GitResultExt<T> for Result<T, E> {
let error_str = e.to_string();
let header = format!("{ERROR_EMOJI} {ERROR}{context}{ERROR:#}");
// External errors always use gutter formatting (canonical path)
- let formatted = format!("{}\n\n{}", header, format_with_gutter(&error_str, "", None));
+ let formatted = format!("{}\n{}", header, format_with_gutter(&error_str, "", None));
GitError::CommandFailed(formatted)
})
}
diff --git a/tests/integration_tests/directives.rs b/tests/integration_tests/directives.rs
index 2284e291f..bbefd76d4 100644
--- a/tests/integration_tests/directives.rs
+++ b/tests/integration_tests/directives.rs
@@ -28,7 +28,6 @@ fn test_switch_internal_directive() {
exit_code: 1
----- stdout -----
❌ Failed to create worktree for my-feature
-
  fatal: invalid reference: my-feature
@@ -58,7 +57,6 @@ fn test_switch_without_internal() {
exit_code: 1
----- stdout -----
❌ Failed to create worktree for my-feature
-
  fatal: invalid reference: my-feature
diff --git a/tests/snapshots/git_error_display__push_failed.snap b/tests/snapshots/git_error_display__push_failed.snap
index 77c73ccf2..09c89630a 100644
--- a/tests/snapshots/git_error_display__push_failed.snap
+++ b/tests/snapshots/git_error_display__push_failed.snap
@@ -3,7 +3,6 @@ source: tests/git_error_display.rs
expression: err.to_string()
---
❌ Push failed
-
  To /Users/user/workspace/repo/.git
  ! [remote rejected] HEAD -> main (Up-to-date check failed)
  error: failed to push some refs to '/Users/user/workspace/repo/.git'
diff --git a/tests/snapshots/git_error_display__worktree_removal_failed.snap b/tests/snapshots/git_error_display__worktree_removal_failed.snap
index 28394cd2b..bb23044d2 100644
--- a/tests/snapshots/git_error_display__worktree_removal_failed.snap
+++ b/tests/snapshots/git_error_display__worktree_removal_failed.snap
@@ -3,6 +3,5 @@ source: tests/git_error_display.rs
expression: err.to_string()
---
❌ Failed to remove worktree for feature-x at /tmp/repo.feature-x
-
  fatal: worktree is dirty
  error: could not remove worktree
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snap b/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snap
index c825227ea..1331d6c04 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_primary_on_different_branch_dirty.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpiUrIVl/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpxaDqD2/test-config.toml
---
success: false
exit_code: 1
@@ -31,7 +31,6 @@ exit_code: 1
✅ Merged to main (1 commit, 1 file, +1)
🔄 Switching to main...
❌ Failed to switch to main
-
  error: Your local changes to the following files would be overwritten by checkout:
  file.txt
  Please commit your changes or stash them before you switch branches.
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap b/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap
index 65c20b6b3..b54a3ee5d 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap
@@ -17,13 +17,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmprBFTsP/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp4vXfy1/test-config.toml
---
success: false
exit_code: 1
----- stdout -----
❌ Failed to load project config
-
  Failed to parse TOML: TOML parse error at line 1, column 39
  |
  1 | post-create-command = [invalid syntax
diff --git a/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snap b/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snap
index ffe17808b..cbd68cfde 100644
--- a/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snap
+++ b/tests/snapshots/integration__integration_tests__security__error_message_with_directive_not_executed.snap
@@ -17,13 +17,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJfokz4/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpXCg30j/test-config.toml
---
success: false
exit_code: 1
----- stdout -----
❌ Failed to create worktree for __WORKTRUNK_EXEC__echo PWNED > /tmp/hacked6
-
  fatal: invalid reference: __WORKTRUNK_EXEC__echo PWNED > /tmp/hacked6