From e3dea37aca19761eef451e4ce282424e9e2689d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 29 Jul 2025 13:59:56 +0200 Subject: [PATCH] Do not rollback branch state in case of a merge failure --- src/sync.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sync.rs b/src/sync.rs index 81fb118..4eaedff 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -177,7 +177,7 @@ This merge was created using https://github.com/rust-lang/josh-sync. // Merge the fetched commit. // It is useful to print stdout/stderr here, because it shows the git diff summary - stream_command( + if let Err(error) = stream_command( &[ "git", "merge", @@ -189,7 +189,16 @@ This merge was created using https://github.com/rust-lang/josh-sync. ], self.verbose, ) - .context("FAILED to merge new commits, something went wrong")?; + .context("FAILED to merge new commits, something went wrong") + { + eprintln!( + r"The merge was unsuccessful (maybe there was a conflict?). +NOT rolling back the branch state, so you can examine it manually. +After you fix the conflicts, `git add` the changes and run `git merge --continue`." + ); + git_reset.disarm(); + return Err(RustcPullError::PullFailed(error)); + } // Now detect if something has actually been pulled let current_sha = get_current_head_sha(self.verbose)?;