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>,
Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH 4/6] merge-ort: expand only for out-of-cone conflicts
Date: Fri, 20 Aug 2021 14:53:35 -0700 [thread overview]
Message-ID: <CABPp-BHZEVgNwd8ziCeAOOMU=Up-DVaOh7oG1ksCVAHT5r+0bg@mail.gmail.com> (raw)
In-Reply-To: <e47b15554e3770571aafe44b4492d2f420f13919.1629220124.git.gitgitgadget@gmail.com>
On Tue, Aug 17, 2021 at 10:08 AM Derrick Stolee via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Derrick Stolee <dstolee@microsoft.com>
>
> Merge conflicts happen often enough to want to avoid expanding a sparse
> index when they happen, as long as those conflicts are within the
> sparse-checkout cone. If a conflict exists outside of the
> sparse-checkout cone, then we still need to expand before iterating over
> the index entries. This is critical to do in advance because of how the
> original_cache_nr is tracked to allow inserting and replacing cache
> entries.
>
> Iterate over the conflicted files and check if any paths are outside of
> the sparse-checkout cone. If so, then expand the full index.
>
> Add a test that demonstrates that we do not expand the index, even when
> we hit a conflict within the sparse-checkout cone.
If I had read ahead a little bit instead of responding as I went.... :-)
Awesome to see this.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
> merge-ort.c | 14 ++++++++---
> t/t1092-sparse-checkout-compatibility.sh | 30 ++++++++++++++++++++++--
> 2 files changed, 39 insertions(+), 5 deletions(-)
>
> diff --git a/merge-ort.c b/merge-ort.c
> index 8e754b769e1..590e52058cf 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -36,6 +36,7 @@
> #include "tree.h"
> #include "unpack-trees.h"
> #include "xdiff-interface.h"
> +#include "dir.h"
dir.h was already included from merge-ort.c; no need to include it
again. (Plus, the original line keeps the nice ordering of the
include list...)
>
> /*
> * We have many arrays of size 3. Whenever we have such an array, the
> @@ -4060,11 +4061,18 @@ static int record_conflicted_index_entries(struct merge_options *opt)
>
> /*
> * We are in a conflicted state. These conflicts might be inside
> - * sparse-directory entries, so expand the index preemtively.
> - * Also, we set original_cache_nr below, but that might change if
> + * sparse-directory entries, so check if any entries are outside
> + * of the sparse-checkout cone preemptively.
> + *
> + * We set original_cache_nr below, but that might change if
> * index_name_pos() calls ask for paths within sparse directories.
> */
> - ensure_full_index(index);
> + strmap_for_each_entry(&opt->priv->conflicted, &iter, e) {
> + if (!path_in_sparse_checkout(e->key, index)) {
> + ensure_full_index(index);
> + break;
> + }
> + }
Sweet, awesome that it was so simple to implement.
>
> /* If any entries have skip_worktree set, we'll have to check 'em out */
> state.force = 1;
> diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
> index 781ebd9a656..a0ed2bec574 100755
> --- a/t/t1092-sparse-checkout-compatibility.sh
> +++ b/t/t1092-sparse-checkout-compatibility.sh
> @@ -622,8 +622,21 @@ test_expect_success 'sparse-index is expanded and converted back' '
> ensure_not_expanded () {
> rm -f trace2.txt &&
> echo >>sparse-index/untracked.txt &&
> - GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
> - git -C sparse-index "$@" &&
> +
> + if test "$1" = "!"
> + then
> + shift &&
> + (
> + GIT_TRACE2_EVENT="$(pwd)/trace2.txt" &&
> + GIT_TRACE2_EVENT_NESTING=10 &&
> + export GIT_TRACE2_EVENT &&
> + export GIT_TRACE2_EVENT_NESTING &&
> + test_must_fail git -C sparse-index "$@" || return 1
> + )
Could this be simplified to
test_must_fail env \
GIT_TRACE2_EVENT="$(pwd)/trace2.txt"
GIT_TRACE2_EVENT_NESTING=10 \
git -C sparse-index "$@" || return 1
?
Especially if the lines can be indented to make it clear that the only
difference between this block and the one below is the "test_must_fail
env" being added at the front.
> + else
> + GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
> + git -C sparse-index "$@" || return 1
> + fi &&
> test_region ! index ensure_full_index trace2.txt
> }
>
> @@ -659,6 +672,19 @@ test_expect_success 'sparse-index is not expanded' '
> ensure_not_expanded merge -s ort -m merge update-folder2
> '
>
> +test_expect_success 'sparse-index is not expanded: merge conflict in cone' '
> + init_repos &&
> +
> + for side in right left
> + do
> + git -C sparse-index checkout -b expand-$side base &&
> + echo $side >sparse-index/deep/a &&
> + git -C sparse-index commit -a -m "$side" || return 1
> + done &&
> +
> + ensure_not_expanded ! merge -m merged expand-right
> +'
> +
> # NEEDSWORK: a sparse-checkout behaves differently from a full checkout
> # in this scenario, but it shouldn't.
> test_expect_success 'reset mixed and checkout orphan' '
> --
> gitgitgadget
>
next prev parent reply other threads:[~2021-08-20 21:53 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 17:08 [PATCH 0/6] Sparse Index: Integrate with merge, cherry-pick, rebase, and revert Derrick Stolee via GitGitGadget
2021-08-17 17:08 ` [PATCH 1/6] t1092: use ORT merge strategy Derrick Stolee via GitGitGadget
2021-08-18 17:16 ` Taylor Blau
2021-08-18 18:10 ` Junio C Hamano
2021-08-18 18:42 ` Derrick Stolee
2021-08-18 22:22 ` Junio C Hamano
2021-08-20 21:23 ` Elijah Newren
2021-08-20 23:32 ` Junio C Hamano
2021-08-21 0:20 ` Elijah Newren
2021-08-21 4:20 ` Junio C Hamano
2021-08-21 23:48 ` Elijah Newren
2021-08-17 17:08 ` [PATCH 2/6] diff: ignore sparse paths in diffstat Derrick Stolee via GitGitGadget
2021-08-20 21:32 ` Elijah Newren
2021-08-24 18:30 ` Derrick Stolee
2021-08-27 22:27 ` Elijah Newren
2021-08-17 17:08 ` [PATCH 3/6] merge: make sparse-aware with ORT Derrick Stolee via GitGitGadget
2021-08-20 21:40 ` Elijah Newren
2021-08-17 17:08 ` [PATCH 4/6] merge-ort: expand only for out-of-cone conflicts Derrick Stolee via GitGitGadget
2021-08-20 21:53 ` Elijah Newren [this message]
2021-08-17 17:08 ` [PATCH 5/6] t1092: add cherry-pick, rebase tests Derrick Stolee via GitGitGadget
2021-08-20 21:58 ` Elijah Newren
2021-08-17 17:08 ` [PATCH 6/6] sparse-index: integrate with cherry-pick and rebase Derrick Stolee via GitGitGadget
2021-08-21 0:12 ` Elijah Newren
2021-08-24 21:52 ` [PATCH v2 0/6] Sparse Index: Integrate with merge, cherry-pick, rebase, and revert Derrick Stolee via GitGitGadget
2021-08-24 21:52 ` [PATCH v2 1/6] diff: ignore sparse paths in diffstat Derrick Stolee via GitGitGadget
2021-08-24 21:52 ` [PATCH v2 2/6] merge: make sparse-aware with ORT Derrick Stolee via GitGitGadget
2021-08-27 22:43 ` Elijah Newren
2021-08-30 17:18 ` Derrick Stolee
2021-09-08 1:49 ` Derrick Stolee
2021-08-24 21:52 ` [PATCH v2 3/6] merge-ort: expand only for out-of-cone conflicts Derrick Stolee via GitGitGadget
2021-08-27 22:47 ` Elijah Newren
2021-08-30 17:21 ` Derrick Stolee
2021-08-24 21:52 ` [PATCH v2 4/6] t1092: add cherry-pick, rebase tests Derrick Stolee via GitGitGadget
2021-08-24 21:52 ` [PATCH v2 5/6] sequencer: ensure full index if not ORT strategy Derrick Stolee via GitGitGadget
2021-08-24 21:52 ` [PATCH v2 6/6] sparse-index: integrate with cherry-pick and rebase Derrick Stolee via GitGitGadget
2021-08-27 22:56 ` [PATCH v2 0/6] Sparse Index: Integrate with merge, cherry-pick, rebase, and revert Elijah Newren
2021-08-30 17:26 ` Derrick Stolee
2021-09-08 11:23 ` [PATCH v3 " Derrick Stolee via GitGitGadget
2021-09-08 11:23 ` [PATCH v3 1/6] diff: ignore sparse paths in diffstat Derrick Stolee via GitGitGadget
2021-09-08 11:23 ` [PATCH v3 2/6] merge: make sparse-aware with ORT Derrick Stolee via GitGitGadget
2021-09-08 11:23 ` [PATCH v3 3/6] merge-ort: expand only for out-of-cone conflicts Derrick Stolee via GitGitGadget
2021-09-08 11:23 ` [PATCH v3 4/6] t1092: add cherry-pick, rebase tests Derrick Stolee via GitGitGadget
2021-09-08 11:24 ` [PATCH v3 5/6] sequencer: ensure full index if not ORT strategy Derrick Stolee via GitGitGadget
2021-09-08 11:24 ` [PATCH v3 6/6] sparse-index: integrate with cherry-pick and rebase Derrick Stolee via GitGitGadget
2021-09-09 14:16 ` [PATCH v3 0/6] Sparse Index: Integrate with merge, cherry-pick, rebase, and revert Elijah Newren
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-BHZEVgNwd8ziCeAOOMU=Up-DVaOh7oG1ksCVAHT5r+0bg@mail.gmail.com' \
--to=newren@gmail.com \
--cc=derrickstolee@github.com \
--cc=dstolee@microsoft.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).