From: Elijah Newren <newren@gmail.com>
To: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Derrick Stolee <stolee@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Derrick Stolee <derrickstolee@github.com>
Subject: Re: [PATCH v3 0/9] More index cleanups
Date: Sat, 23 Jan 2021 12:29:21 -0800 [thread overview]
Message-ID: <CABPp-BHFiXLOS4Vbm156+JxZw=t2P_Fzf8E3p4u0iwCv28_Rdw@mail.gmail.com> (raw)
In-Reply-To: <pull.839.v3.git.1611431899.gitgitgadget@gmail.com>
On Sat, Jan 23, 2021 at 11:58 AM Derrick Stolee via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> This is based on ds/cache-tree-basics.
>
> Here are a few more cleanups that are vaguely related to the index. I
> discovered these while preparing my sparse-index RFC that I intend to send
> early next week.
>
> The biggest patch is the final one, which creates a test script for
> comparing sparse-checkouts to full checkouts. There are some commands that
> do not behave similarly. This script will be the backbone of my testing
> strategy for the sparse-index by adding a new mode to compare
> sparse-checkouts with the two index types (full and sparse).
>
>
> UPDATES IN V3
> =============
>
> * Callers to cache_tree_update() no longer initialize the cache_tree in
> advance.
>
> * Added a patch to update verify_cache() prototype.
>
> * Added missing "pos + 1" in fsmonitor.c.
>
> * Added a BUG() statement when repo->istate->repo is already populated, but
> not equal to repo.
>
> * Cleaned up test_region pattern quoting. Thanks, Junio!
>
> Thanks, -Stolee
>
> Derrick Stolee (9):
> cache-tree: clean up cache_tree_update()
> cache-tree: simplify verify_cache() prototype
> cache-tree: extract subtree_pos()
> fsmonitor: de-duplicate BUG()s around dirty bits
> repository: add repo reference to index_state
> name-hash: use trace2 regions for init
> sparse-checkout: load sparse-checkout patterns
> test-lib: test_region looks for trace2 regions
> t1092: test interesting sparse-checkout scenarios
>
> builtin/checkout.c | 3 -
> builtin/sparse-checkout.c | 5 -
> cache-tree.c | 38 +--
> cache-tree.h | 2 +
> cache.h | 1 +
> dir.c | 17 ++
> dir.h | 2 +
> fsmonitor.c | 27 +-
> name-hash.c | 3 +
> repository.c | 6 +
> sequencer.c | 3 -
> t/t0500-progress-display.sh | 3 +-
> t/t1092-sparse-checkout-compatibility.sh | 301 +++++++++++++++++++++++
> t/test-lib-functions.sh | 42 ++++
> unpack-trees.c | 8 +-
> 15 files changed, 408 insertions(+), 53 deletions(-)
> create mode 100755 t/t1092-sparse-checkout-compatibility.sh
>
>
> base-commit: a4b6d202caad83c6dc29abe9b17e53a1b3fb54a0
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-839%2Fderrickstolee%2Fmore-index-cleanups-v3
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-839/derrickstolee/more-index-cleanups-v3
> Pull-Request: https://github.com/gitgitgadget/git/pull/839
>
> Range-diff vs v2:
>
> 1: f9dccaed0ac ! 1: bdc8ecca3d2 cache-tree: clean up cache_tree_update()
> @@ Commit message
> BUG() statement or returning with an error because future callers will
> want to populate an empty cache-tree using this method.
>
> - Also drop local variables that are used exactly once and can be found
> - directly from the 'istate' parameter.
> + Callers can also remove their conditional allocations of cache_tree.
> +
> + Also drop local variables that can be found directly from the 'istate'
> + parameter.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
>
> + ## builtin/checkout.c ##
> +@@ builtin/checkout.c: static int merge_working_tree(const struct checkout_opts *opts,
> + }
> + }
> +
> +- if (!active_cache_tree)
> +- active_cache_tree = cache_tree();
> +-
> + if (!cache_tree_fully_valid(active_cache_tree))
> + cache_tree_update(&the_index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
> +
> +
> ## cache-tree.c ##
> @@ cache-tree.c: static int update_one(struct cache_tree *it,
>
> @@ cache-tree.c: static int update_one(struct cache_tree *it,
> trace2_region_leave("cache_tree", "update", the_repository);
> trace_performance_leave("cache_tree_update");
> if (i < 0)
> +@@ cache-tree.c: static int write_index_as_tree_internal(struct object_id *oid,
> + cache_tree_valid = 0;
> + }
> +
> +- if (!index_state->cache_tree)
> +- index_state->cache_tree = cache_tree();
> +-
> + if (!cache_tree_valid && cache_tree_update(index_state, flags) < 0)
> + return WRITE_TREE_UNMERGED_INDEX;
> +
> +
> + ## sequencer.c ##
> +@@ sequencer.c: static int do_recursive_merge(struct repository *r,
> +
> + static struct object_id *get_cache_tree_oid(struct index_state *istate)
> + {
> +- if (!istate->cache_tree)
> +- istate->cache_tree = cache_tree();
> +-
> + if (!cache_tree_fully_valid(istate->cache_tree))
> + if (cache_tree_update(istate, 0)) {
> + error(_("unable to update cache tree"));
> +
> + ## unpack-trees.c ##
> +@@ unpack-trees.c: int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
> + if (!ret) {
> + if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
> + cache_tree_verify(the_repository, &o->result);
> +- if (!o->result.cache_tree)
> +- o->result.cache_tree = cache_tree();
> + if (!cache_tree_fully_valid(o->result.cache_tree))
> + cache_tree_update(&o->result,
> + WRITE_TREE_SILENT |
> -: ----------- > 2: 1b8b5680094 cache-tree: simplify verify_cache() prototype
> 2: 84323e04d08 = 3: 314b6b34f75 cache-tree: extract subtree_pos()
> 3: 31095f9aa0e ! 4: 4e688d25f8c fsmonitor: de-duplicate BUG()s around dirty bits
> @@ Commit message
> cannot simplify it too much. However, the error string is identical in
> each, so this simplifies things.
>
> + Be sure to add one when checking if a position if valid, since the
> + minimum is a bound on the expected size.
> +
> The end result is that the code is simpler to read while also preserving
> these assertions for developers in the FSMonitor space.
>
> @@ fsmonitor.c
> - if (pos >= istate->cache_nr)
> - BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" >= %u)",
> - (uintmax_t)pos, istate->cache_nr);
> -+ assert_index_minimum(istate, pos);
> ++ assert_index_minimum(istate, pos + 1);
>
> ce = istate->cache[pos];
> ce->ce_flags &= ~CE_FSMONITOR_VALID;
> 4: a0d89d7a973 ! 5: 6373997e05c repository: add repo reference to index_state
> @@ Commit message
> repository, add a 'repo' pointer to struct index_state that allows
> access to this repository.
>
> + Add a BUG() statement if the repo already has an index, and the index
> + already has a repo, but somehow the index points to a different repo.
> +
> This will prevent future changes from needing to pass an additional
> 'struct repository *repo' parameter and instead rely only on the 'struct
> index_state *istate' parameter.
> @@ repository.c: int repo_read_index(struct repository *repo)
> + /* Complete the double-reference */
> + if (!repo->index->repo)
> + repo->index->repo = repo;
> ++ else if (repo->index->repo != repo)
> ++ BUG("repo's index should point back at itself");
> +
> return read_index_from(repo->index, repo->index_file, repo->gitdir);
> }
> 5: bc092f5c703 = 6: 9b545d7dbec name-hash: use trace2 regions for init
> 6: 04d1daf7222 = 7: 554cc7647e6 sparse-checkout: load sparse-checkout patterns
> 7: 8832ce84623 ! 8: b37181bdec4 test-lib: test_region looks for trace2 regions
> @@ t/test-lib-functions.sh: test_subcommand () {
> + shift
> + fi
> +
> -+ grep -e "\"region_enter\".*\"category\":\"$1\",\"label\":\"$2\"" "$3"
> ++ grep -e '"region_enter".*"category":"'"$1"'","label":"'"$2"\" "$3"
> + exitcode=$?
> +
> -+ if test $exitcode != $expect_exit
> ++ if test $exitcode != $expect_exit = 1]
I don't understand this change. Is it even valid code? What does it mean?
> + then
> + return 1
> + fi
> +
> -+ grep -e "\"region_leave\".*\"category\":\"$1\",\"label\":\"$2\"" "$3"
> ++ grep -e '"region_leave".*"category":"'"$1"'","label":"'"$2"\" "$3"
> + exitcode=$?
> +
> -+ if test $exitcode != $expect_exit
> ++ if test $exitcode != $expect_exit = 1]
Same comment.
> + then
> + return 1
> + fi
> ++
> ++ return 0
> +}
> 8: 984458007ed ! 9: 72f925353d3 t1092: test interesting sparse-checkout scenarios
> @@ t/t1092-sparse-checkout-compatibility.sh (new)
> + echo a >a &&
> + echo "after deep" >e &&
> + echo "after folder1" >g &&
> ++ echo "after x" >z &&
> + mkdir folder1 folder2 deep x &&
> + mkdir deep/deeper1 deep/deeper2 &&
> + mkdir deep/deeper1/deepest &&
> @@ t/t1092-sparse-checkout-compatibility.sh (new)
> + echo "after deepest" >deep/deeper1/e &&
> + cp a folder1 &&
> + cp a folder2 &&
> ++ cp a x &&
> + cp a deep &&
> + cp a deep/deeper1 &&
> + cp a deep/deeper2 &&
> + cp a deep/deeper1/deepest &&
> ++ cp -r deep/deeper1/deepest deep/deeper2 &&
> + git add . &&
> + git commit -m "initial commit" &&
> + git checkout -b base &&
>
Having read the previous rounds, the rest of the range-diff looks good
to me; I sent out separate comments on the new patch.
next prev parent reply other threads:[~2021-01-23 20:30 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 16:53 [PATCH 0/9] More index cleanups Derrick Stolee via GitGitGadget
2021-01-20 16:53 ` [PATCH 1/9] cache-tree: clean up cache_tree_update() Derrick Stolee via GitGitGadget
2021-01-20 17:21 ` Elijah Newren
2021-01-20 19:10 ` Derrick Stolee
2021-01-20 16:53 ` [PATCH 2/9] cache-tree: extract subtree_pos() Derrick Stolee via GitGitGadget
2021-01-20 17:23 ` Elijah Newren
2021-01-20 16:53 ` [PATCH 3/9] fsmonitor: de-duplicate BUG()s around dirty bits Derrick Stolee via GitGitGadget
2021-01-20 17:26 ` Elijah Newren
2021-01-21 12:53 ` Chris Torek
2021-01-21 15:56 ` Derrick Stolee
2021-01-20 16:53 ` [PATCH 4/9] repository: add repo reference to index_state Derrick Stolee via GitGitGadget
2021-01-20 17:46 ` Elijah Newren
2021-01-20 19:16 ` Derrick Stolee
2021-01-20 19:50 ` Elijah Newren
2021-01-20 16:53 ` [PATCH 5/9] name-hash: use trace2 regions for init Derrick Stolee via GitGitGadget
2021-01-20 17:47 ` Elijah Newren
2021-01-20 16:53 ` [PATCH 6/9] sparse-checkout: load sparse-checkout patterns Derrick Stolee via GitGitGadget
2021-01-20 17:54 ` Elijah Newren
2021-01-20 16:53 ` [PATCH 7/9] sparse-checkout: hold pattern list in index Derrick Stolee via GitGitGadget
2021-01-20 18:03 ` Elijah Newren
2021-01-20 19:22 ` Derrick Stolee
2021-01-20 16:53 ` [PATCH 8/9] test-lib: test_region looks for trace2 regions Derrick Stolee via GitGitGadget
2021-01-20 18:20 ` Elijah Newren
2021-01-20 19:24 ` Derrick Stolee
2021-01-20 16:53 ` [PATCH 9/9] t1092: test interesting sparse-checkout scenarios Derrick Stolee via GitGitGadget
2021-01-20 19:40 ` Elijah Newren
2021-01-21 11:59 ` Derrick Stolee
2021-01-22 13:03 ` [PATCH v2 0/8] More index cleanups Derrick Stolee via GitGitGadget
2021-01-22 13:03 ` [PATCH v2 1/8] cache-tree: clean up cache_tree_update() Derrick Stolee via GitGitGadget
2021-01-22 19:11 ` Junio C Hamano
2021-01-22 13:03 ` [PATCH v2 2/8] cache-tree: extract subtree_pos() Derrick Stolee via GitGitGadget
2021-01-22 13:03 ` [PATCH v2 3/8] fsmonitor: de-duplicate BUG()s around dirty bits Derrick Stolee via GitGitGadget
2021-01-22 19:18 ` Junio C Hamano
2021-01-22 13:03 ` [PATCH v2 4/8] repository: add repo reference to index_state Derrick Stolee via GitGitGadget
2021-01-22 19:23 ` Junio C Hamano
2021-01-22 13:03 ` [PATCH v2 5/8] name-hash: use trace2 regions for init Derrick Stolee via GitGitGadget
2021-01-22 13:03 ` [PATCH v2 6/8] sparse-checkout: load sparse-checkout patterns Derrick Stolee via GitGitGadget
2021-01-22 13:03 ` [PATCH v2 7/8] test-lib: test_region looks for trace2 regions Derrick Stolee via GitGitGadget
2021-01-22 19:42 ` Junio C Hamano
2021-01-23 18:36 ` Derrick Stolee
2021-01-23 18:50 ` Junio C Hamano
2021-01-22 13:03 ` [PATCH v2 8/8] t1092: test interesting sparse-checkout scenarios Derrick Stolee via GitGitGadget
2021-01-22 19:49 ` [PATCH v2 0/8] More index cleanups Elijah Newren
2021-01-23 18:47 ` Derrick Stolee
2021-01-23 19:58 ` [PATCH v3 0/9] " Derrick Stolee via GitGitGadget
2021-01-23 19:58 ` [PATCH v3 1/9] cache-tree: clean up cache_tree_update() Derrick Stolee via GitGitGadget
2021-01-23 19:58 ` [PATCH v3 2/9] cache-tree: simplify verify_cache() prototype Derrick Stolee via GitGitGadget
2021-01-23 20:24 ` Elijah Newren
2021-01-23 21:02 ` Derrick Stolee
2021-01-23 21:10 ` Elijah Newren
2021-01-23 21:41 ` Junio C Hamano
2021-01-23 21:10 ` Junio C Hamano
2021-01-23 21:14 ` Derrick Stolee
2021-01-23 19:58 ` [PATCH v3 3/9] cache-tree: extract subtree_pos() Derrick Stolee via GitGitGadget
2021-01-23 19:58 ` [PATCH v3 4/9] fsmonitor: de-duplicate BUG()s around dirty bits Derrick Stolee via GitGitGadget
2021-01-23 19:58 ` [PATCH v3 5/9] repository: add repo reference to index_state Derrick Stolee via GitGitGadget
2021-01-23 19:58 ` [PATCH v3 6/9] name-hash: use trace2 regions for init Derrick Stolee via GitGitGadget
2021-01-23 19:58 ` [PATCH v3 7/9] sparse-checkout: load sparse-checkout patterns Derrick Stolee via GitGitGadget
2021-01-23 19:58 ` [PATCH v3 8/9] test-lib: test_region looks for trace2 regions Derrick Stolee via GitGitGadget
2021-01-23 21:07 ` Derrick Stolee
2021-01-23 19:58 ` [PATCH v3 9/9] t1092: test interesting sparse-checkout scenarios Derrick Stolee via GitGitGadget
2021-01-25 18:45 ` Elijah Newren
2021-01-23 20:29 ` Elijah Newren [this message]
2021-01-23 21:05 ` [PATCH v3 0/9] More index cleanups Derrick Stolee
2021-01-23 21:42 ` Junio C Hamano
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='CABPp-BHFiXLOS4Vbm156+JxZw=t2P_Fzf8E3p4u0iwCv28_Rdw@mail.gmail.com' \
--to=newren@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=stolee@gmail.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).