diff --git a/commands.cpp b/commands.cpp index d25c4cc..9c19b3c 100644 --- a/commands.cpp +++ b/commands.cpp @@ -183,15 +183,19 @@ static void deconfigure_git_filters (const char* key_name) } } -static bool git_checkout (const std::vector& paths) +static bool git_checkout_batch (std::vector::const_iterator paths_begin, std::vector::const_iterator paths_end) { + if (paths_begin == paths_end) { + return true; + } + std::vector command; command.push_back("git"); command.push_back("checkout"); command.push_back("--"); - for (std::vector::const_iterator path(paths.begin()); path != paths.end(); ++path) { + for (auto path(paths_begin); path != paths_end; ++path) { command.push_back(*path); } @@ -202,6 +206,18 @@ static bool git_checkout (const std::vector& paths) return true; } +static bool git_checkout (const std::vector& paths) +{ + auto paths_begin(paths.begin()); + while (paths.end() - paths_begin >= 100) { + if (!git_checkout_batch(paths_begin, paths_begin + 100)) { + return false; + } + paths_begin += 100; + } + return git_checkout_batch(paths_begin, paths.end()); +} + static bool same_key_name (const char* a, const char* b) { return (!a && !b) || (a && b && std::strcmp(a, b) == 0);