Re: [PATCH v2 3/7] read-tree: expand sparse checkout test coverage
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Feb 28, 2022, 23:09 UTC
- Message-ID
- <220301.861qzm37qt.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <ffe0b6aff2baee238f77ae57561a62ea5473321f.1645742073.git.gitgitgadget@gmail.com>
On Thu, Feb 24 2022, Victoria Dye via GitGitGadget wrote:
Show 60 quoted lines
> From: Victoria Dye <vdye@github.com> > > Add tests focused on how 'git read-tree' behaves in sparse checkouts. Extra > emphasis is placed on interactions with files outside the sparse cone, e.g. > merges with out-of-cone conflicts. > > Signed-off-by: Victoria Dye <vdye@github.com> > --- > t/perf/p2000-sparse-operations.sh | 1 + > t/t1092-sparse-checkout-compatibility.sh | 85 ++++++++++++++++++++++++ > 2 files changed, 86 insertions(+) > > diff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh > index 2a7106b9495..382716cfca9 100755 > --- a/t/perf/p2000-sparse-operations.sh > +++ b/t/perf/p2000-sparse-operations.sh > @@ -117,6 +117,7 @@ test_perf_on_all git diff > test_perf_on_all git diff --cached > test_perf_on_all git blame $SPARSE_CONE/a > test_perf_on_all git blame $SPARSE_CONE/f3/a > +test_perf_on_all git read-tree -mu HEAD > test_perf_on_all git checkout-index -f --all > test_perf_on_all git update-index --add --remove $SPARSE_CONE/a > > diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh > index b1dcaa0e642..9d58da4e925 100755 > --- a/t/t1092-sparse-checkout-compatibility.sh > +++ b/t/t1092-sparse-checkout-compatibility.sh > @@ -819,6 +819,91 @@ test_expect_success 'update-index --cacheinfo' ' > test_cmp expect sparse-checkout-out > ' > > +test_expect_success 'read-tree --merge with files outside sparse definition' ' > + init_repos && > + > + test_all_match git checkout -b test-branch update-folder1 && > + for MERGE_TREES in "base HEAD update-folder2" \ > + "update-folder1 update-folder2" \ > + "update-folder2" > + do > + # Clean up and remove on-disk files > + test_all_match git reset --hard HEAD && > + test_sparse_match git sparse-checkout reapply && > + > + # Although the index matches, without --no-sparse-checkout, outside-of- > + # definition files will not exist on disk for sparse checkouts > + test_all_match git read-tree -mu $MERGE_TREES && > + test_all_match git status --porcelain=v2 && > + test_path_is_missing sparse-checkout/folder2 && > + test_path_is_missing sparse-index/folder2 && > + > + test_all_match git read-tree --reset -u HEAD && > + test_all_match git status --porcelain=v2 && > + > + test_all_match git read-tree -mu --no-sparse-checkout $MERGE_TREES && > + test_all_match git status --porcelain=v2 && > + test_cmp sparse-checkout/folder2/a sparse-index/folder2/a && > + test_cmp sparse-checkout/folder2/a full-checkout/folder2/a || return 1 > + done > +'
Nit: Isn't this nicer/easier by unrolling the for-loop to the top-level, i.e.:
for MERGE_TREES in "base HEAD update-folder2" [...]
do
test_expect_success "'read-tree -mu $MERGE_TREES' with files outside sparse definition" '
init_repos &&
test_when_finished "test_all_match git reset --hard HEAD" &&
...
'
doneIt makes failures easier to reason about since you see which for-loop iteration you're in right away, and can e.g. pick one with --run.
And we can do the cleanup in test_when_finished instead of at the start of every loop.