From 84c8fcc3996589cd6ab2fbc72a91767541d836f8 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Sun, 11 Aug 2024 16:57:27 +0300 Subject: [PATCH 1/2] During cloning by default all submodules init parallel using all CPU threads https://github.com/soramimi/Guitar/issues/148 (#148) https://github.com/soramimi/Guitar/issues/139 (#139) --- src/Git.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Git.cpp b/src/Git.cpp index caf3d019..02d0fecc 100644 --- a/src/Git.cpp +++ b/src/Git.cpp @@ -14,6 +14,7 @@ #include #include #include +#include Git::CommitID::CommitID() { @@ -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); }; From d6e217089d4e4c41a284fdd3f6d21fdf06ae7736 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Sun, 11 Aug 2024 17:18:31 +0300 Subject: [PATCH 2/2] git fetch by default parallel and using all CPU threads --- src/Git.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Git.cpp b/src/Git.cpp index 02d0fecc..0ef1cd2c 100644 --- a/src/Git.cpp +++ b/src/Git.cpp @@ -1359,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"; } @@ -1370,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);