Skip to content

Commit

Permalink
Revert: stack commit message (#9671)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmiossec committed Oct 26, 2021
1 parent 46b3ad4 commit 6c873f4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions GitUI/CommandsDialogs/FormRevertCommit.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using GitCommands;
using GitCommands.Git.Commands;
using GitUI.HelperDialogs;
using GitUIPluginInterfaces;
Expand Down Expand Up @@ -81,12 +82,28 @@ private void Revert_Click(object sender, EventArgs e)
}
}

var commitMessageManager = new CommitMessageManager(Module.WorkingDirGitDir, Module.CommitEncoding);

string existingCommitMessage = commitMessageManager.MergeOrCommitMessage;

var command = GitCommandHelpers.RevertCmd(Revision.ObjectId, AutoCommit.Checked, parentIndex);

// Don't verify whether the command is successful.
// If it fails, likely there is a conflict that needs to be resolved.
FormProcess.ShowDialog(this, arguments: command, Module.WorkingDir, input: null, useDialogSettings: true);

if (!string.IsNullOrWhiteSpace(existingCommitMessage))
{
try
{
string newCommitMessageContent = $"{existingCommitMessage}\n\n{commitMessageManager.MergeOrCommitMessage}";
commitMessageManager.WriteCommitMessageToFile(newCommitMessageContent, CommitMessageType.Merge, usingCommitTemplate: false, ensureCommitMessageSecondLineEmpty: false);
}
catch (Exception)
{
}
}

MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
DialogResult = DialogResult.OK;
Close();
Expand Down

0 comments on commit 6c873f4

Please sign in to comment.