git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Derrick Stolee <derrickstolee@github.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Victoria Dye <vdye@github.com>,
	Jeff Hostetler <jeffhost@microsoft.com>
Subject: Re: [PATCH 3/5] sparse-index API: fix TODO, BUG() out on NULL ensure_full_index()
Date: Tue, 10 Jan 2023 09:58:51 -0500	[thread overview]
Message-ID: <14271f92-0ee4-906c-2e12-954ce74fd3ef@github.com> (raw)
In-Reply-To: <patch-3.5-d96388acef6-20230110T060340Z-avarab@gmail.com>

On 1/10/2023 1:17 AM, Ævar Arnfjörð Bjarmason wrote: 
> The only reason it needed to be this lax was due to interaction with
> repo_index_has_changes(). See the addition of that code in . This
> fixes one of the TODO comments added in 0c18c059a15, the other one was
> already removed in [3].

> 2. 0c18c059a15 (read-cache: ensure full index, 2021-04-01)
> 3. d76723ee531 (status: use sparse-index throughout, 2021-07-14).

> -	} else {
> -		/* TODO: audit for interaction with sparse-index. */

Please don't drop this comment. It was inserted on purpose before the
"ensure_full_index(istate)" as an indicator that the following loop
has not been checked to see if it could be run on a sparse index.

Removing the comment is like saying "this loop was checked and we
_must_ use a full index here". The case of the TODO being removed in
[3] was because the loop was audited as being safe on a sparse index
(and the ensure_full_index() call was removed). I don't believe that
is what you have done here.

> +	} else if (istate) {
>  		ensure_full_index(istate);
>  		for (i = 0; sb && i < istate->cache_nr; i++) {
>  			if (i)

Further, this block has all sorts of direct uses of 'istate'
that would cause a segfault if 'istate' was NULL. Why do we need
to check for non-NULL now?

Looking earlier in the function, 'istate' is initialized to
'repo->index', so the function already assumed the repository had
an initialized index (or "tree || !get_oid_tree("HEAD", &cmp)"
was satisfied, which doesn't seem connected to a NULL index).

So, I'm thinking that we don't actually need any change to
repo_index_has_changes() unless it's being called in new ways
further down in the series.

Thanks,
-Stolee

  parent reply	other threads:[~2023-01-10 14:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10  6:17 [PATCH 0/5] cache API: always have a "istate->repo" Ævar Arnfjörð Bjarmason
2023-01-10  6:17 ` [PATCH 1/5] builtin/difftool.c: { 0 }-initialize rather than using memset() Ævar Arnfjörð Bjarmason
2023-01-10  6:17 ` [PATCH 2/5] sparse-index.c: expand_to_path() can assume non-NULL "istate" Ævar Arnfjörð Bjarmason
2023-01-10  6:17 ` [PATCH 3/5] sparse-index API: fix TODO, BUG() out on NULL ensure_full_index() Ævar Arnfjörð Bjarmason
2023-01-10 10:35   ` Philip Oakley
2023-01-10 12:22     ` Ævar Arnfjörð Bjarmason
2023-01-10 14:58   ` Derrick Stolee [this message]
2023-01-10  6:17 ` [PATCH 4/5] read-cache.c: refactor set_new_index_sparsity() for subsequent commit Ævar Arnfjörð Bjarmason
2023-01-10  6:17 ` [PATCH 5/5] treewide: always have a valid "index_state.repo" member Ævar Arnfjörð Bjarmason
2023-01-10 12:24   ` Ævar Arnfjörð Bjarmason
2023-01-10 13:13   ` Jeff Hostetler
2023-01-10 15:08   ` Derrick Stolee
2023-01-10 15:09 ` [PATCH 0/5] cache API: always have a "istate->repo" Derrick Stolee
2023-01-12 12:55 ` [PATCH v2 0/6] " Ævar Arnfjörð Bjarmason
2023-01-12 12:55   ` [PATCH v2 1/6] builtin/difftool.c: { 0 }-initialize rather than using memset() Ævar Arnfjörð Bjarmason
2023-01-12 12:55   ` [PATCH v2 2/6] sparse-index.c: expand_to_path() can assume non-NULL "istate" Ævar Arnfjörð Bjarmason
2023-01-12 12:55   ` [PATCH v2 3/6] sparse-index API: BUG() out on NULL ensure_full_index() Ævar Arnfjörð Bjarmason
2023-01-12 12:55   ` [PATCH v2 4/6] read-cache.c: refactor set_new_index_sparsity() for subsequent commit Ævar Arnfjörð Bjarmason
2023-01-12 12:55   ` [PATCH v2 5/6] cache API: add a "INDEX_STATE_INIT" macro/function, add release_index() Ævar Arnfjörð Bjarmason
2023-01-12 15:21     ` Derrick Stolee
2023-01-12 16:19       ` Ævar Arnfjörð Bjarmason
2023-01-12 16:47         ` Derrick Stolee
2023-01-12 12:55   ` [PATCH v2 6/6] treewide: always have a valid "index_state.repo" member Ævar Arnfjörð Bjarmason
2023-01-12 15:22     ` Derrick Stolee
2023-01-12 15:23   ` [PATCH v2 0/6] cache API: always have a "istate->repo" Derrick Stolee
2023-01-13 18:29     ` Junio C Hamano
2023-01-13 19:22   ` Junio C Hamano
2023-01-16 13:38     ` Ævar Arnfjörð Bjarmason
2023-01-16 16:53       ` Philip Oakley
2023-01-16 18:39         ` Junio C Hamano
2023-01-17 13:57           ` [PATCH] treewide: always have a valid "index_state.repo" member Ævar Arnfjörð Bjarmason
2023-01-17 15:34             ` Derrick Stolee

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=14271f92-0ee4-906c-2e12-954ce74fd3ef@github.com \
    --to=derrickstolee@github.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.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).