Commit e48bb71b by Russell Belfer

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.
parent fe67e404
...@@ -30,6 +30,7 @@ struct checkout_diff_data ...@@ -30,6 +30,7 @@ struct checkout_diff_data
git_indexer_stats *stats; git_indexer_stats *stats;
git_repository *owner; git_repository *owner;
bool can_symlink; bool can_symlink;
bool found_submodules;
bool create_submodules; bool create_submodules;
int error; int error;
}; };
...@@ -242,6 +243,8 @@ static int checkout_create_the_new( ...@@ -242,6 +243,8 @@ static int checkout_create_the_new(
if (do_checkout) { if (do_checkout) {
bool is_submodule = S_ISGITLINK(delta->old_file.mode); bool is_submodule = S_ISGITLINK(delta->old_file.mode);
data->found_submodules = true;
if (!is_submodule && !data->create_submodules) if (!is_submodule && !data->create_submodules)
error = checkout_blob(data, &delta->old_file); error = checkout_blob(data, &delta->old_file);
...@@ -339,7 +342,8 @@ int git_checkout_index( ...@@ -339,7 +342,8 @@ int git_checkout_index(
stats = &dummy_stats; stats = &dummy_stats;
stats->processed = 0; 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)); memset(&data, 0, sizeof(data));
...@@ -365,7 +369,8 @@ int git_checkout_index( ...@@ -365,7 +369,8 @@ int git_checkout_index(
if (!(error = git_diff_foreach( if (!(error = git_diff_foreach(
diff, &data, checkout_remove_the_old, NULL, NULL)) && diff, &data, checkout_remove_the_old, NULL, NULL)) &&
!(error = git_diff_foreach( !(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; data.create_submodules = true;
error = git_diff_foreach( error = git_diff_foreach(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment