Skip to content

Commit

Permalink
Merge pull request #149 from GermanAizek/clone-with-parallel-subodule…
Browse files Browse the repository at this point in the history
…s-update

Cloning by default all submodules init parallel using all CPU threads #148/#139
  • Loading branch information
soramimi authored Sep 17, 2024
2 parents 819d3d0 + d6e2170 commit 7ad143e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Git.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QThread>
#include <QTimer>
#include <optional>
#include <thread>

Git::CommitID::CommitID()
{
Expand Down Expand Up @@ -1042,8 +1043,8 @@ bool Git::clone(CloneData const &data, AbstractPtyProcess *pty)
QDir cwd = QDir::current();

auto DoIt = [&](){
QString cmd = "clone --progress \"%1\" \"%2\"";
cmd = cmd.arg(data.url).arg(data.subdir);
QString cmd = "clone --recurse-submodules --progress -j%1 \"%2\" \"%3\"";
cmd = cmd.arg(std::thread::hardware_concurrency()).arg(data.url).arg(data.subdir);
ok = git_nochdir(cmd, pty);
};

Expand Down Expand Up @@ -1358,7 +1359,8 @@ bool Git::pull(AbstractPtyProcess *pty)

bool Git::fetch(AbstractPtyProcess *pty, bool prune)
{
QString cmd = "fetch --tags -f";
QString cmd = "fetch --tags -f -j%1";
cmd = cmd.arg(std::thread::hardware_concurrency());
if (prune) {
cmd += " --prune";
}
Expand All @@ -1369,7 +1371,8 @@ bool Git::fetch(AbstractPtyProcess *pty, bool prune)

bool Git::fetch_tags_f(AbstractPtyProcess *pty)
{
QString cmd = "fetch --tags -f";
QString cmd = "fetch --tags -f -j%1";
cmd = cmd.arg(std::thread::hardware_concurrency());
Option opt;
opt.pty = pty;
return git(cmd, opt);
Expand Down

0 comments on commit 7ad143e

Please sign in to comment.