From e2761c221f2b26d3aff9c35334bd3400b2695de1 Mon Sep 17 00:00:00 2001 From: JC-Chung <52159296+JC-Chung@users.noreply.github.com> Date: Fri, 6 Nov 2026 12:14:16 +0800 Subject: [PATCH 1/2] fix: commit message not loaded after cherry-pick/revert with `--no-commit` --- src/ViewModels/WorkingCopy.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index ad663a01b..1d32c21a8 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -810,12 +810,16 @@ private void UpdateInProgressState() else InProgressContext = null; + var mergeMsg = Path.Combine(_repo.GitDir, "MERGE_MSG"); + if (_inProgressContext == null) { if (Directory.Exists(Path.Combine(_repo.GitDir, "rebase-apply"))) Directory.Delete(Path.Combine(_repo.GitDir, "rebase-apply"), true); - if (oldType != null && IsAutoLoadedCommitMessage()) + // MERGE_MSG may exist without an in-progress marker (e.g. after + // `git cherry-pick -n` or `git revert -n`), so try loading it first. + if (!LoadCommitMessageFromFile(mergeMsg) && oldType != null && IsAutoLoadedCommitMessage()) CommitMessage = string.Empty; return; @@ -824,7 +828,7 @@ private void UpdateInProgressState() if (_inProgressContext.GetType() == oldType && !string.IsNullOrEmpty(_commitMessage)) return; - if (LoadCommitMessageFromFile(Path.Combine(_repo.GitDir, "MERGE_MSG"))) + if (LoadCommitMessageFromFile(mergeMsg)) return; if (_inProgressContext is RebaseInProgress rebasing) From 3dd2f8f2802defa04c7b49f31dab9409ca61969f Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 6 Nov 2026 14:55:27 +0800 Subject: [PATCH 2/2] code_review: auto-load commit message --- src/ViewModels/Repository.cs | 3 +++ src/ViewModels/WorkingCopy.cs | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index e303facd5..4d3b5541c 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -481,7 +481,10 @@ public void Close() { var commitMessage = _workingCopy.CommitMessage; if (!string.IsNullOrEmpty(commitMessage) && _workingCopy.InProgressContext != null) + { File.WriteAllText(Path.Combine(GitDir, "MERGE_MSG"), commitMessage); + commitMessage = string.Empty; // Clears this from ui-state, since it is already saved in MERGE_MSG file. + } _uiStates.LastCommitMessage = commitMessage; _uiStates.Save(); diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 1d32c21a8..9b8508bd5 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -810,17 +810,15 @@ private void UpdateInProgressState() else InProgressContext = null; - var mergeMsg = Path.Combine(_repo.GitDir, "MERGE_MSG"); - if (_inProgressContext == null) { if (Directory.Exists(Path.Combine(_repo.GitDir, "rebase-apply"))) Directory.Delete(Path.Combine(_repo.GitDir, "rebase-apply"), true); - // MERGE_MSG may exist without an in-progress marker (e.g. after - // `git cherry-pick -n` or `git revert -n`), so try loading it first. - if (!LoadCommitMessageFromFile(mergeMsg) && oldType != null && IsAutoLoadedCommitMessage()) + if (oldType != null && IsAutoLoadedCommitMessage()) CommitMessage = string.Empty; + else if (string.IsNullOrEmpty(_commitMessage)) + LoadCommitMessageFromFile(Path.Combine(_repo.GitDir, "MERGE_MSG")); return; } @@ -828,7 +826,7 @@ private void UpdateInProgressState() if (_inProgressContext.GetType() == oldType && !string.IsNullOrEmpty(_commitMessage)) return; - if (LoadCommitMessageFromFile(mergeMsg)) + if (LoadCommitMessageFromFile(Path.Combine(_repo.GitDir, "MERGE_MSG"))) return; if (_inProgressContext is RebaseInProgress rebasing)