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

Re: [PATCH v2] submodule-config: fix reading submodule.fetchJobs

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2026, 00:01 UTC
Message-ID
<xmqq4ikgb0ac.fsf@gitster.g>
In-Reply-To
<CAN5EUNTPiu7p=M8CZB_3Rcbsn34eEZC6YeiA3NW2zM7zSS42HQ@mail.gmail.com>
Pablo <pabloosabaterr@gmail.com> writes:
Show 22 quoted lines
> El dom, 3 may 2026 a las 13:57, Saagar Jha via GitGitGadget
> (<gitgitgadget@gmail.com>) escribió:
>>
>> From: Saagar Jha <saagar@saagarjha.com>
>>
>> The old code accidentally passed &max_jobs rather than max_jobs into
>> config_from_gitmodules, which caused the setting to be written to the
>> wrong place and dropped.
>
> Better, but we can improve this, following
> Documentation/SubmittingPatches [1], it is better to write in present
> tense something like:
>
>   update_clone_config_from_gitmodules() passes &max_jobs to
>   config_from_gitmodules(), but max_jobs is already a pointer.
>   This causes the config value to be written to the wrong address
>   and dropped.
>
>   Pass max_jobs directly.
>
> I recommend reading Documentation/SubmittingPatches:
>   [1]: https://github.com/git/git/blob/master/Documentation/SubmittingPatches

Very well said. And your version reads more natural in the context of this project, to those who are used to "git log --no-merges".

The config_from_gitmodules() function takes (void *) as the third parameter unfortunately, which forces the compiler to take any pointer without complaints. Typically an "int" is the same size as or narrower than a "(void *)", and has no stricter alignment requirement than "(int *)", so passing the address of max_int (i.e., "&max_int") would have caused the callee to assign an "int" result to the on-stack "max_int" variable, corrupting the pointer but otherwise causing no crashes, since the pointer is not used after the function returns. That is why we never noticed this at either compile time or runtime. Only those who paid attention to the actual return value, like the test added by this patch, would have noticed it. Nicely done.

Show 9 quoted lines
>> +test_expect_success 'submodule update honors fetch jobs config from .gitmodules' '
>> +       test_when_finished "rm -rf super3" &&
>> +       git clone cloned super3 &&
>> +       (cd super3 &&
>> +        git config -f .gitmodules submodule.fetchJobs 67 &&
>> +        GIT_TRACE="$(pwd)/trace.out" git submodule update --init &&
>> +        grep "67 tasks" trace.out
>> +       )
>> +'

This inherited badness from existing tests in the same script, but in the modern tests, the abouve would be written more like

test_expect_success 'submodule update honors fetch jobs config from .gitmodules' '
	test_when_finished "rm -rf super3" &&
	git clone cloned super3 &&
	(
		cd super3 &&
		git config -f .gitmodules submodule.fetchJobs 67 &&
		GIT_TRACE="$(pwd)/trace.out" git submodule update --init &&
		test_grep "67 tasks" trace.out
	)
'
in order to
 (1) open-close parentheses for subshell on their own lines;
 (2) test_grep to make the error stand out more when it fails
or avoiding a subshell altogether and do
test_expect_success 'submodule update honors fetch jobs config from .gitmodules' '
	test_when_finished "rm -rf super3" &&
	git clone cloned super3 &&
	git -C super3 config -f .gitmodules submodule.fetchJobs 67 &&
	GIT_TRACE="$(pwd)/trace.out" git -C super3 submodule update --init &&
	test_grep "67 tasks" trace.out
'
Previous: PabloNext: Saagar Jha via GitGitGadget
Message 7 of 9 in “submodule-config: fix reading submodule.fetchJobs”
  1. submodule-config: fix reading submodule.fetchJobsSaagar Jha via GitGitGadget, May 3, 2026
  2. PabloMay 3, 2026
  3. Saagar JhaMay 3, 2026
  4. PabloMay 3, 2026
  5. submodule-config: fix reading submodule.fetchJobsSaagar Jha via GitGitGadget, May 3, 2026
  6. PabloMay 3, 2026
  7. Junio C HamanoMay 10, 2026
  8. submodule-config: fix reading submodule.fetchJobsSaagar Jha via GitGitGadget, May 3, 2026
  9. submodule-config: fix reading submodule.fetchJobsSaagar Jha via GitGitGadget, May 10, 2026

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.