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

[PATCH] Add a check to prevent max_children from being 0.

From
AGAlex via GitGitGadget <gitgitgadget@gmail.com>
Date
May 23, 2025, 16:20 UTC
Message-ID
<pull.1975.git.git.1748017238130.gitgitgadget@gmail.com>
From: jinyaoguo <guo846@purdue.edu>

In function fetch_multiple and fetch_submodules, `multiple` is stored in `opt.process` and later used as a divisor in function `pp_collect_finished`, creating a potential divide-by-zero if it remains zero.

Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
    Add a check to prevent max_children from being 0, which may cause
    potential divide-by-zero.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1975%2Fmugitya03%2Fint2-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1975/mugitya03/int2-v1
Pull-Request: https://github.com/git/git/pull/1975
 builtin/fetch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index cda6eaf1fd6..b668187627a 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2591,7 +2591,7 @@ int cmd_fetch(int argc,
 			die(_("--stdin can only be used when fetching "
 			      "from one remote"));
 
-		if (max_children < 0)
+		if (max_children <= 0)
 			max_children = config.parallel;
 
 		/* TODO should this also die if we have a previous partial-clone? */
@@ -2613,9 +2613,9 @@ int cmd_fetch(int argc,
 		struct strvec options = STRVEC_INIT;
 		int max_children = max_jobs;
 
-		if (max_children < 0)
+		if (max_children <= 0)
 			max_children = config.submodule_fetch_jobs;
-		if (max_children < 0)
+		if (max_children <= 0)
 			max_children = config.parallel;
 
 		add_options_to_argv(&options, &config);

base-commit: 8613c2bb6cd16ef530dc5dd74d3b818a1ccbf1c0
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 3 in “Add a check to prevent max_children from being 0.”
  1. Add a check to prevent max_children from being 0.Alex via GitGitGadget, May 23, 2025
  2. Junio C HamanoMay 23, 2025
  3. Jinyao GuoMay 25, 2025

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.