From: Nitro Cao <jaycecao520@gmail.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, gitgitgadget@gmail.com, jaycecao520@gmail.com
Subject:
Date: Sun, 8 Feb 2026 23:25:51 +0800 [thread overview]
Message-ID: <20260208152551.93473-1-jaycecao520@gmail.com> (raw)
In-Reply-To: <xmqqfr7hsk63.fsf@gitster.g>
Hi Junio and thanks for your time! I'm a newbie, sorry for the last
reply :(
> While your change may skip the code that segfaults, wouldn't it also
> stop noticing a broken case where .peer_ref should have been set but
> didn't, even when --revision=<rev> parameter is not used in the
> command invocation? IOW, it is better to segfault and draw attention
> by Git developers when a valid input is given by the end user and our
> code misbehaves (e.g., and fails to to set .peer_ref as it should).
I totally agree with you.
> Wouldn't the correct fix be more like the following?
>
> - split out parts from update_remote_refs() that are needed even in
> option_rev mode into a separate helper function, and call that
> from cmd_clone().
>
> - make the call to update_remote_refs() conditional---specifically,
> we shouldn't be calling it when option_rev is in effect.
Do we have another fix to make a conditional call to `find_ref_by_name()`
when `option_rev` is in effect? Because from the doc of `--revision`,
"... and detach `HEAD` to_<rev>_. ...", that means we don't need to
know where the real HEAD points to?
> Also, isn't this something we can specify the expected behaviour in
> tests? Not only we want to ensure that nothing segfaults, we would
> want to make sure that the resulting repository has no refs and HEAD
> is detached at the specified revision.
I'll add several tests to cover the bug after we make sure how to fix it.
prev parent reply other threads:[~2026-02-08 15:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-01 9:23 [PATCH] fix(clone): segment fault when using --revision and protocol v0/v1 NitroCao via GitGitGadget
2026-02-03 11:56 ` [PATCH v2] clone: fix segfault when using --revision and v0/v1 protocol NitroCao via GitGitGadget
2026-02-03 19:26 ` Junio C Hamano
2026-02-08 15:25 ` Nitro Cao [this message]
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=20260208152551.93473-1-jaycecao520@gmail.com \
--to=jaycecao520@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox