Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/ViewModels/WorkingCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ private void UpdateInProgressState()
if (_inProgressContext != null && _inProgressContext.GetType() == oldType && !string.IsNullOrEmpty(_commitMessage))
return;

// The operation that filled the commit message ended outside SourceGit (for example, a
// rebase or merge finished/aborted from the terminal). Drop the stale message unless the
// user has edited it since it was loaded.
if (_inProgressContext == null && oldType != null && IsAutoLoadedCommitMessage())
CommitMessage = string.Empty;

if (LoadCommitMessageFromFile(Path.Combine(_repo.GitDir, "MERGE_MSG")))
return;

Expand All @@ -816,7 +822,7 @@ private void UpdateInProgressState()
if (LoadCommitMessageFromFile(Path.Combine(_repo.GitDir, "rebase-merge", "message")))
return;

CommitMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, rebasing.StoppedAt.SHA).GetResult();
SetAutoLoadedCommitMessage(new Commands.QueryCommitFullMessage(_repo.FullPath, rebasing.StoppedAt.SHA).GetResult());
}

private bool LoadCommitMessageFromFile(string file)
Expand All @@ -828,10 +834,22 @@ private bool LoadCommitMessageFromFile(string file)
if (string.IsNullOrEmpty(msg))
return false;

CommitMessage = msg;
SetAutoLoadedCommitMessage(msg);
return true;
}

private void SetAutoLoadedCommitMessage(string msg)
{
_autoLoadedCommitMessage = msg;
CommitMessage = msg;
}

private bool IsAutoLoadedCommitMessage()
{
return !string.IsNullOrEmpty(_autoLoadedCommitMessage) &&
string.Equals(_autoLoadedCommitMessage, _commitMessage, StringComparison.Ordinal);
}

private void SetDetail(Models.Change change, bool isUnstaged)
{
if (_isLoadingData)
Expand Down Expand Up @@ -942,5 +960,6 @@ public ChangeInTree(Models.Change change)

private bool _hasUnsolvedConflicts = false;
private InProgressContext _inProgressContext = null;
private string _autoLoadedCommitMessage = null;
}
}