Instead of sorting it after we created an unsorted list, we could insert
correctly into the list.  As the unsorted append is in order of cache entry
names, this is already sorted if names were equal to paths for submodules.

As submodule names are often the same as their path, the input is sorted
pretty well already, so let's just do the sort afterwards.

Signed-off-by: Stefan Beller <sbel...@google.com>
---
 submodule.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/submodule.c b/submodule.c
index 8345d423fda..8bee455137a 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1255,7 +1255,7 @@ static int get_next_submodule(struct child_process *cp,
                default:
                case RECURSE_SUBMODULES_DEFAULT:
                case RECURSE_SUBMODULES_ON_DEMAND:
-                       if (!submodule || !unsorted_string_list_lookup(
+                       if (!submodule || !string_list_lookup(
                                        &changed_submodule_names,
                                        submodule->name))
                                continue;
@@ -1349,6 +1349,7 @@ int fetch_populated_submodules(struct repository *r,
        /* default value, "--submodule-prefix" and its value are added later */
 
        calculate_changed_submodule_paths();
+       string_list_sort(&changed_submodule_names);
        run_processes_parallel(max_parallel_jobs,
                               get_next_submodule,
                               fetch_start_failure,
-- 
2.19.0.rc1.350.ge57e33dbd1-goog

Reply via email to