git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Derrick Stolee <derrickstolee@github.com>
To: Victoria Dye via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: shaoxuan.yuan02@gmail.com, gitster@pobox.com,
	Victoria Dye <vdye@github.com>
Subject: Re: [PATCH] unpack-trees: fix sparse directory recursion check
Date: Fri, 2 Sep 2022 09:32:01 -0400	[thread overview]
Message-ID: <8dea9ffe-d03b-f838-6cc5-db0de5024d9f@github.com> (raw)
In-Reply-To: <pull.1344.git.1662066153644.gitgitgadget@gmail.com>

On 9/1/2022 5:02 PM, Victoria Dye via GitGitGadget wrote:
> From: Victoria Dye <vdye@github.com>
> 
> Ensure 'is_sparse_directory_entry()' receives a valid 'name_entry *' if one
> exists in the list of tree(s) being unpacked in 'unpack_callback()'.
> 
> Currently, 'is_sparse_directory_entry()' is called with the first
> 'name_entry' in the 'names' list of entries on 'unpack_callback()'. However,
> this entry may be empty even when other elements of 'names' are not (such as
> when switching from an orphan branch back to a "normal" branch). As a
> result, 'is_sparse_directory_entry()' could incorrectly indicate that a
> sparse directory is *not* actually sparse because the name of the index
> entry does not match the (empty) 'name_entry' path.

Thank you for finding the root cause here. It was very non-obvious!

> +test_expect_success 'checkout orphan then non-orphan' '
> +	init_repos &&
> +
> +	test_all_match git checkout --orphan test-orphan &&
> +	test_all_match git status --porcelain=v2 &&
> +	test_all_match git checkout base &&
> +	test_all_match git status --porcelain=v2
> +'
> +

This test demonstrates how specific the case needs to be for this to
actually happen.

Could it also happen if we are going from a commit without that
sparse directory and then to a commit with that sparse directory? I
think that would be a more common case, but I was unable to
manipulate the test repo in t1092 to trigger this bug in the existing
test cases.

This makes me think that this bug _is_ extremely rare, so we don't
need to rush this into a 2.37.4 or anything. It would be good to
bring it into 2.38.0-rc0, though.

Thanks!
-Stolee

  parent reply	other threads:[~2022-09-02 14:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01 21:02 [PATCH] unpack-trees: fix sparse directory recursion check Victoria Dye via GitGitGadget
2022-09-02  9:03 ` Johannes Schindelin
2022-09-02 13:32 ` Derrick Stolee [this message]
2022-09-02 16:57   ` Junio C Hamano
2022-09-02 19:03 ` Shaoxuan Yuan

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=8dea9ffe-d03b-f838-6cc5-db0de5024d9f@github.com \
    --to=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=shaoxuan.yuan02@gmail.com \
    --cc=vdye@github.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;
as well as URLs for NNTP newsgroup(s).