From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 01/14] revision: defensive programming
Date: Thu, 15 May 2025 10:13:20 -0700 [thread overview]
Message-ID: <xmqq8qmx23wv.fsf@gitster.g> (raw)
In-Reply-To: <604e67ee64167efd5282b9efabbcb6e72eeaf5e6.1747313140.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Thu, 15 May 2025 12:45:26 +0000")
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> On the off chance that `lookup_decoration()` cannot find anything, let
> `leave_one_treesame_to_parent()` return gracefully instead of crashing.
But wouldn't it be a BUG("") worthy event for the treesame
decoration not to exist for the commit object in question at this
point of the code? Is it really defensive to silently pretend that
nothing bad happened and to move forward?
> Pointed out by CodeQL.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> revision.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/revision.c b/revision.c
> index c4390f0938cb..59eae4eb8ba8 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -3359,6 +3359,9 @@ static int leave_one_treesame_to_parent(struct rev_info *revs, struct commit *co
> struct commit_list *p;
> unsigned n;
>
> + if (!ts)
> + return 0;
> +
> for (p = commit->parents, n = 0; p; p = p->next, n++) {
> if (ts->treesame[n]) {
> if (p->item->object.flags & TMP_MARK) {
next prev parent reply other threads:[~2025-05-15 17:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 12:45 [PATCH 00/14] Some defensive programming Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 01/14] revision: " Johannes Schindelin via GitGitGadget
2025-05-15 17:13 ` Junio C Hamano [this message]
2025-05-15 12:45 ` [PATCH 02/14] get_parent(): " Johannes Schindelin via GitGitGadget
2025-05-15 17:21 ` Junio C Hamano
2025-05-15 20:32 ` Jeff King
2025-05-15 12:45 ` [PATCH 03/14] fetch-pack: " Johannes Schindelin via GitGitGadget
2025-05-15 17:24 ` Junio C Hamano
2025-05-15 12:45 ` [PATCH 04/14] unparse_commit(): " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 05/14] verify_commit_graph(): " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 06/14] stash: " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 07/14] " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 08/14] push: " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 09/14] fetch: " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 10/14] describe: " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 11/14] inherit_tracking(): " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 12/14] submodule: check return value of `submodule_from_path()` Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 13/14] test-tool repository: check return value of `lookup_commit()` Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 14/14] shallow: handle missing shallow commits gracefully Johannes Schindelin 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=xmqq8qmx23wv.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johannes.schindelin@gmx.de \
/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;
as well as URLs for NNTP newsgroup(s).