summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-10-17 10:44:38 -0700
committerRussell Belfer <rb@github.com>2012-10-17 10:44:38 -0700
commite48bb71bec20d6edbce4fc5c77b716ae0701e33a (patch)
treee0f6564c9d2d9ad8dc90b05162d6228da296c8e0
parentfe67e404da4230149ada1b94acadf7dde828b22e (diff)
downloadlibgit2-e48bb71bec20d6edbce4fc5c77b716ae0701e33a.tar.gz
Skip submodule checkout pass if no submodules
Skip the third pass of checkout (where submodules are checked out) if the earlier passes found no submodules to be checked out.
-rw-r--r--src/checkout.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 6f5cfffd7..74ac379a5 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -30,6 +30,7 @@ struct checkout_diff_data
git_indexer_stats *stats;
git_repository *owner;
bool can_symlink;
+ bool found_submodules;
bool create_submodules;
int error;
};
@@ -242,6 +243,8 @@ static int checkout_create_the_new(
if (do_checkout) {
bool is_submodule = S_ISGITLINK(delta->old_file.mode);
+ data->found_submodules = true;
+
if (!is_submodule && !data->create_submodules)
error = checkout_blob(data, &delta->old_file);
@@ -339,7 +342,8 @@ int git_checkout_index(
stats = &dummy_stats;
stats->processed = 0;
- stats->total = (unsigned int)git_diff_num_deltas(diff) * 3 /* # passes */;
+ /* total based on 3 passes, but it might be 2 if no submodules */
+ stats->total = (unsigned int)git_diff_num_deltas(diff) * 3;
memset(&data, 0, sizeof(data));
@@ -365,7 +369,8 @@ int git_checkout_index(
if (!(error = git_diff_foreach(
diff, &data, checkout_remove_the_old, NULL, NULL)) &&
!(error = git_diff_foreach(
- diff, &data, checkout_create_the_new, NULL, NULL)))
+ diff, &data, checkout_create_the_new, NULL, NULL)) &&
+ data.found_submodules)
{
data.create_submodules = true;
error = git_diff_foreach(