builtin/submodule--helper: factor out method to update a single submodule

In a later patch we'll find this method handy. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Aug 3, 2018 at 15:23 UTC c94d9dc286027e0343ffd58b5f7f2899691f6747
1 file changed +10 -10
builtin/submodule--helper.c
+10 -10
@@ -1727,10 +1727,17 @@ static int git_update_clone_config(const char *var, const char *value,
1727 return 0;
1728 }
1729
1730 +static void update_submodule(struct update_clone_data *ucd)
1731 +{
1732 + fprintf(stdout, "dummy %s %d\t%s\n",
1733 + oid_to_hex(&ucd->oid),
1734 + ucd->just_cloned,
1735 + ucd->sub->path);
1736 +}
1737 +
1738 static int update_submodules(struct submodule_update_clone *suc)
1739 {
1740 int i;
1733 - struct strbuf sb = STRBUF_INIT;
1741
1742 run_processes_parallel(suc->max_jobs,
1743 update_clone_get_next_task,
@@ -1749,16 +1756,9 @@ static int update_submodules(struct submodule_update_clone *suc)
1756 if (suc->quickstop)
1757 return 1;
1758
1752 - for (i = 0; i < suc->update_clone_nr; i++) {
1753 - strbuf_addf(&sb, "dummy %s %d\t%s\n",
1754 - oid_to_hex(&suc->update_clone[i].oid),
1755 - suc->update_clone[i].just_cloned,
1756 - suc->update_clone[i].sub->path);
1757 - fprintf(stdout, "%s", sb.buf);
1758 - strbuf_reset(&sb);
1759 - }
1759 + for (i = 0; i < suc->update_clone_nr; i++)
1760 + update_submodule(&suc->update_clone[i]);
1761
1761 - strbuf_release(&sb);
1762 return 0;
1763 }
1764