All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Pablo <pabloosabaterr@gmail.com>
Cc: Saagar Jha via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org,  Saagar Jha <saagar@saagarjha.com>
Subject: Re: [PATCH v2] submodule-config: fix reading submodule.fetchJobs
Date: Sun, 10 May 2026 09:01:15 +0900	[thread overview]
Message-ID: <xmqq4ikgb0ac.fsf@gitster.g> (raw)
In-Reply-To: <CAN5EUNTPiu7p=M8CZB_3Rcbsn34eEZC6YeiA3NW2zM7zSS42HQ@mail.gmail.com> (Pablo's message of "Sun, 3 May 2026 15:07:04 +0200")

Pablo <pabloosabaterr@gmail.com> writes:

> 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.

>> +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
'


  reply	other threads:[~2026-05-10  0:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-03 10:14 [PATCH] submodule-config: fix reading submodule.fetchJobs Saagar Jha via GitGitGadget
2026-05-03 11:07 ` Pablo
2026-05-03 11:24   ` Saagar Jha
2026-05-03 12:19     ` Pablo
2026-05-03 11:57 ` [PATCH v2] " Saagar Jha via GitGitGadget
2026-05-03 13:07   ` Pablo
2026-05-10  0:01     ` Junio C Hamano [this message]
2026-05-03 13:52   ` [PATCH v3] " Saagar Jha via GitGitGadget
2026-05-10  3:50     ` [PATCH v4] " Saagar Jha via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4ikgb0ac.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=pabloosabaterr@gmail.com \
    --cc=saagar@saagarjha.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.