Skip to content

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

Removes diffstat from non-fast-forward error

Maximilian Roos957544ee0651
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index dfe64d184..fb98d43aa 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -501,23 +501,7 @@ pub fn handle_push(
.trim()
.to_string();
- // Get formatted diff stat (full terminal width - no gutter in error display)
- let term_width = crate::display::get_terminal_width();
- let files_formatted = repo
- .run_command(&[
- "diff",
- "--color=always",
- "--stat",
- &format!("--stat-width={}", term_width),
- &format!("HEAD...{}", target_branch),
- ])?
- .trim_end()
- .to_string();
-
- bail!(
- "{}",
- not_fast_forward(&target_branch, &commits_formatted, &files_formatted)
- );
+ bail!("{}", not_fast_forward(&target_branch, &commits_formatted));
}
// Check for merge commits unless allowed
diff --git a/src/git/error.rs b/src/git/error.rs
index 67a0a9cf2..9bea38595 100644
--- a/src/git/error.rs
+++ b/src/git/error.rs
@@ -164,23 +164,14 @@ pub fn conflicting_changes(files: &[String], worktree_path: &Path) -> anyhow::Er
}
/// Not fast-forward error
-pub fn not_fast_forward(
- target_branch: &str,
- commits_formatted: &str,
- files_formatted: &str,
-) -> anyhow::Error {
+pub fn not_fast_forward(target_branch: &str, commits_formatted: &str) -> anyhow::Error {
let mut msg = format!(
- "{ERROR_EMOJI} {ERROR}Can't push to local {ERROR_BOLD}{target_branch}{ERROR_BOLD:#}{ERROR} branch: it has newer commits{ERROR:#}\n"
+ "{ERROR_EMOJI} {ERROR}Can't push to local {ERROR_BOLD}{target_branch}{ERROR_BOLD:#}{ERROR} branch: it has newer commits{ERROR:#}"
);
if !commits_formatted.is_empty() {
msg.push('\n');
- msg.push_str(commits_formatted);
- }
-
- if !files_formatted.is_empty() {
- msg.push('\n');
- msg.push_str(files_formatted);
+ msg.push_str(&format_with_gutter(commits_formatted, "", None));
}
msg.push_str(&format!(