aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git/gitclient.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/gitclient.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/gitclient.cpp')
-rw-r--r--src/plugins/git/gitclient.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index f925abcc13f..c7b00f02a9f 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -3558,18 +3558,21 @@ bool GitClient::synchronousRevert(const FilePath &workingDirectory, const QStrin
return executeAndHandleConflicts(workingDirectory, {command, "--no-edit", commit}, command);
}
-bool GitClient::synchronousCherryPick(const FilePath &workingDirectory, const QString &commit)
+bool GitClient::synchronousCherryPick(const FilePath &workingDirectory, const QStringList &commits)
{
+ if (commits.isEmpty())
+ return false;
+
const QString command = "cherry-pick";
// "commit" might be --continue or --abort
- const bool isRealCommit = !commit.startsWith('-');
+ const bool isRealCommit = !commits.first().startsWith('-');
if (isRealCommit && !beginStashScope(workingDirectory, command))
return false;
QStringList arguments = {command};
- if (isRealCommit && isRemoteCommit(workingDirectory, commit))
+ if (isRealCommit && isRemoteCommit(workingDirectory, commits.first()))
arguments << "-x";
- arguments << commit;
+ arguments << commits;
return executeAndHandleConflicts(workingDirectory, arguments, command);
}
@@ -3912,7 +3915,7 @@ void GitClient::addChangeActions(QMenu *menu, const FilePath &source, const QStr
const FilePath &workingDir = fileWorkingDirectory(source);
const bool isRange = change.contains("..");
menu->addAction(Tr::tr("Cherr&y-Pick %1").arg(change), [workingDir, change] {
- gitClient().synchronousCherryPick(workingDir, change);
+ gitClient().synchronousCherryPick(workingDir, {change});
});
menu->addAction(Tr::tr("Re&vert %1").arg(change), [workingDir, change] {
gitClient().synchronousRevert(workingDir, change);