From 89bcafa1a6f2643492a2f6c60525fe1a3c0ecc85 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Sat, 25 Jan 2020 10:21:23 -0500 Subject: [PATCH] Use an enum for git checkout batch size instead of hard-coding constant --- commands.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/commands.cpp b/commands.cpp index 9c19b3c..81c401d 100644 --- a/commands.cpp +++ b/commands.cpp @@ -51,6 +51,12 @@ #include #include +enum { + // # of arguments per git checkout call; must be large enough to be efficient but small + // enough to avoid operating system limits on argument length + GIT_CHECKOUT_BATCH_SIZE = 100 +}; + static std::string attribute_name (const char* key_name) { if (key_name) { @@ -209,11 +215,11 @@ static bool git_checkout_batch (std::vector::const_iterator paths_b 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)) { + while (paths.end() - paths_begin >= GIT_CHECKOUT_BATCH_SIZE) { + if (!git_checkout_batch(paths_begin, paths_begin + GIT_CHECKOUT_BATCH_SIZE)) { return false; } - paths_begin += 100; + paths_begin += GIT_CHECKOUT_BATCH_SIZE; } return git_checkout_batch(paths_begin, paths.end()); }