aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git/gitplugin.cpp
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2025-12-06 14:55:14 +0100
committerAndré Hartmann <aha_1980@gmx.de>2025-12-12 16:34:36 +0000
commit84d789a010becb0ba0908e215e5ec0c39ff2c669 (patch)
tree704e201ddda34c597cbcf60af3e97ab99331de9c /src/plugins/git/gitplugin.cpp
parent8f8b6fd2e371244ec965a770330e2c515f4b58dc (diff)
Git: BranchView: Allow cherry-picking a list of commits
... instead only the top commit of the selected branch. Change-Id: I42cb6e682afd239ee374f475215e580288b5a681 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins/git/gitplugin.cpp')
-rw-r--r--src/plugins/git/gitplugin.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index febb81d2a4e..784fb6129cb 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -247,6 +247,7 @@ public:
void cleanRepository();
void updateSubmodules();
void createPatchesFromCommits();
+ void cherryPickCommits(const QString &branch);
void applyCurrentFilePatch();
void applyClipboardPatch();
void promptApplyPatch();
@@ -808,7 +809,7 @@ GitPluginPrivate::GitPluginPrivate()
//: Avoid translating "Cherry Pick"
m_abortCherryPickAction = createAction(Tr::tr("Abort Cherry Pick"), "Git.CherryPickAbort",
- std::bind(&GitClient::synchronousCherryPick, &gitClient(), _1, QString("--abort")));
+ std::bind(&GitClient::synchronousCherryPick, &gitClient(), _1, QStringList("--abort")));
//: Avoid translating "Cherry Pick"
m_continueCherryPickAction = createAction(Tr::tr("Continue Cherry Pick"), "Git.CherryPickContinue",
@@ -1310,7 +1311,7 @@ void GitPluginPrivate::startChangeRelatedAction(const Id &id)
switch (dialog.command()) {
case CherryPick:
- gitClient().synchronousCherryPick(workingDirectory, change);
+ gitClient().synchronousCherryPick(workingDirectory, {change});
break;
case Revert:
gitClient().synchronousRevert(workingDirectory, change);
@@ -1605,7 +1606,7 @@ void GitPluginPrivate::createPatchesFromCommits()
LogChangeDialog dialog(LogChangeDialog::Select, Core::ICore::dialogParent());
PatchItemDelegate delegate(dialog.widget());
- dialog.setContiguousSelectionEnabled(true);
+ dialog.setSelectionMode(QAbstractItemView::ContiguousSelection);
dialog.setWindowTitle(Tr::tr("Select Commits for Patch Creation"));
const Utils::FilePath topLevel = state.topLevel();
@@ -1613,6 +1614,24 @@ void GitPluginPrivate::createPatchesFromCommits()
gitClient().formatPatch(topLevel, dialog.patchRange());
}
+void GitPluginPrivate::cherryPickCommits(const QString &branch)
+{
+ const VcsBasePluginState state = currentState();
+ QTC_ASSERT(state.hasTopLevel(), return);
+
+ LogChangeDialog dialog(LogChangeDialog::Select, Core::ICore::dialogParent());
+ PatchItemDelegate delegate(dialog.widget());
+ dialog.setSelectionMode(QAbstractItemView::MultiSelection);
+ dialog.setWindowTitle(Tr::tr("Select Commits to Cherry-Pick"));
+
+ const Utils::FilePath topLevel = state.topLevel();
+ const uint flags = LogChangeWidget::IncludeRemotes | LogChangeWidget::OmitMerges;
+ if (dialog.runDialog(topLevel, branch, LogChangeWidget::LogFlags(flags))) {
+ const QStringList commits = dialog.commitList();
+ gitClient().synchronousCherryPick(topLevel, commits);
+ }
+}
+
// If the file is modified in an editor, make sure it is saved.
static bool ensureFileSaved(const QString &fileName)
{
@@ -2346,6 +2365,11 @@ class GITSHARED_EXPORT GitPlugin final : public ExtensionSystem::IPlugin
}
};
+void cherryPickCommits(const QString &branch)
+{
+ dd->cherryPickCommits(branch);
+}
+
} // Git::Internal
#include "gitplugin.moc"