git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/6] builtin/submodule--helper: factor out method to update a single submodule

From
Stefan Beller <sbeller@google.com>
Date
Jul 12, 2018, 19:47 UTC
Message-ID
<20180712194754.71979-6-sbeller@google.com>
In-Reply-To
<20180712194754.71979-1-sbeller@google.com>
In a later patch we'll find this method handy.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/submodule--helper.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c9c3fe2bf28..4bbf580df79 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1725,10 +1725,17 @@ static int gitmodules_update_clone_config(const char *var, const char *value,
 	return 0;
 }
 
+static void update_submodule(struct submodule_update_clone_information *suci)
+{
+	fprintf(stdout, "dummy %s %d\t%s\n",
+		oid_to_hex(&suci->oid),
+		suci->just_cloned,
+		suci->sub->path);
+}
+
 static int update_submodules(struct submodule_update_clone *suc)
 {
 	int i;
-	struct strbuf sb = STRBUF_INIT;
 
 	run_processes_parallel(suc->max_jobs,
 			       update_clone_get_next_task,
@@ -1747,16 +1754,9 @@ static int update_submodules(struct submodule_update_clone *suc)
 	if (suc->quickstop)
 		return 1;
 
-	for (i = 0; i < suc->submodule_lines_nr; i++) {
-		strbuf_addf(&sb, "dummy %s %d\t%s\n",
-			oid_to_hex(&suc->submodule_lines[i].oid),
-			suc->submodule_lines[i].just_cloned,
-			suc->submodule_lines[i].sub->path);
-		fprintf(stdout, "%s", sb.buf);
-		strbuf_reset(&sb);
-	}
+	for (i = 0; i < suc->submodule_lines_nr; i++)
+		update_submodule(&suc->submodule_lines[i]);
 
-	strbuf_release(&sb);
 	return 0;
 }
 
-- 
2.18.0.203.gfac676dfb9-goog
Previous: Stefan BellerNext: Stefan Beller
Message 10 of 13 in “git-submodule.sh: convert part of cmd_update to C”
  1. 0/6 git-submodule.sh: convert part of cmd_update to CStefan Beller, Jul 12, 2018
  2. 1/6 git-submodule.sh: align error reporting for update mode to use pathStefan Beller, Jul 12, 2018
  3. Junio C HamanoJul 12, 2018
  4. 2/6 git-submodule.sh: rename unused variablesStefan Beller, Jul 12, 2018
  5. Junio C HamanoJul 12, 2018
  6. 3/6 builtin/submodule--helper: factor out submodule updatingStefan Beller, Jul 12, 2018
  7. 4/6 builtin/submodule--helper: store update_clone information in a structStefan Beller, Jul 12, 2018
  8. Junio C HamanoJul 16, 2018
  9. Stefan BellerJul 16, 2018
  10. 5/6 builtin/submodule--helper: factor out method to update a single submoduleStefan Beller, Jul 12, 2018
  11. 6/6 submodule--helper: introduce new update-module-mode helperStefan Beller, Jul 12, 2018
  12. Derrick StoleeJul 18, 2018
  13. Stefan BellerJul 18, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.