Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat(rebase): Display git output for conflicts
Maximilian Roos977640c81018
diff --git a/src/commands/dev.rs b/src/commands/dev.rsindex 03926822e..32190c04f 100644--- a/src/commands/dev.rs+++ b/src/commands/dev.rs@@ -324,9 +324,15 @@ pub fn handle_dev_rebase(target: Option<&str>) -> Result<(), GitError> {if let Some(state) = repo.worktree_state()?&& state.starts_with("REBASING"){+ // Extract git's stderr output from the error+ let git_output = match &e {+ GitError::CommandFailed(msg) => msg.clone(),+ _ => e.to_string(),+ };return Err(GitError::RebaseConflict {state,target_branch: target_branch.to_string(),+ git_output,});}// Not a rebase conflict, return original error@@ -341,6 +347,7 @@ pub fn handle_dev_rebase(target: Option<&str>) -> Result<(), GitError> {return Err(GitError::RebaseConflict {state,target_branch: target_branch.to_string(),+ git_output: String::new(), // No error output in this edge case});}diff --git a/src/git.rs b/src/git.rsindex a3b5700ef..75bfdfabc 100644--- a/src/git.rs+++ b/src/git.rs@@ -68,6 +68,7 @@ pub enum GitError {RebaseConflict {state: String,target_branch: String,+ git_output: String,},}@@ -227,14 +228,30 @@ impl std::fmt::Display for GitError {// Rebase conflictGitError::RebaseConflict {- state,+ state: _,target_branch,+ git_output,} => {+ use crate::styling::format_with_gutter;let error_bold = ERROR.bold();+write!(f,- "{ERROR_EMOJI} {ERROR}Rebase onto {ERROR:#}{error_bold}{target_branch}{error_bold:#}{ERROR} incomplete: {state}{ERROR:#}\n\n{HINT_EMOJI} {HINT}Resolve conflicts and run 'git rebase --continue'{HINT:#}\n{HINT_EMOJI} {HINT}Or abort with 'git rebase --abort'{HINT:#}"- )+ "{ERROR_EMOJI} {ERROR}Rebase onto {ERROR:#}{error_bold}{target_branch}{error_bold:#}{ERROR} incomplete{ERROR:#}"+ )?;++ if !git_output.is_empty() {+ writeln!(f)?;+ write!(f, "{}", format_with_gutter(git_output, "", None))?;+ } else {+ // Fallback hints if no git output (edge case)+ write!(+ f,+ "\n\n{HINT_EMOJI} {HINT}Resolve conflicts and run 'git rebase --continue'{HINT:#}\n{HINT_EMOJI} {HINT}Or abort with 'git rebase --abort'{HINT:#}"+ )?;+ }++ Ok(())}}}diff --git a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snapindex 35571ea86..46c27d504 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap@@ -12,11 +12,10 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: /dev/nullGIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpkIyPq0/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpDxsSjV/test-config.toml---success: falseexit_code: 1@@ -25,7 +24,11 @@ exit_code: 1π [36mRebasing onto [0m[1m[36mmain[0m[36m...[0m----- stderr ------β [31mRebase onto [0m[1m[31mmain[0m[31m incomplete: REBASING 1/1[0m--π‘ [2mResolve conflicts and run 'git rebase --continue'[0m-π‘ [2mOr abort with 'git rebase --abort'[0m+β [31mRebase onto [0m[1m[31mmain[0m[31m incomplete[0m+[40m [0m Rebasing (1/1) error: could not apply [SHA]... Update shared.txt in feature+[40m [0m hint: Resolve all conflicts manually, mark them as resolved with+[40m [0m hint: "git add/rm <conflicted_files>", then run "git rebase --continue".+[40m [0m hint: You can instead skip this commit: run "git rebase --skip".+[40m [0m hint: To abort and get back to the state before "git rebase", run "git rebase --abort".+[40m [0m hint: Disable this message with "git config set advice.mergeConflict false"+[40m [0m Could not apply [SHA]... # Update shared.txt in feature