git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>, Taylor Blau <me@ttaylorr.com>,
	Derrick Stolee <derrickstolee@github.com>,
	Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH v2 2/6] merge: make sparse-aware with ORT
Date: Fri, 27 Aug 2021 15:43:00 -0700	[thread overview]
Message-ID: <CABPp-BEF0htk-Q-+wiF+XgTWRRtDc5FPJKauWZAivLGuMgWeAQ@mail.gmail.com> (raw)
In-Reply-To: <bb150483bcfd0469cd88bab735bc1178fb6628f5.1629841966.git.gitgitgadget@gmail.com>

On Tue, Aug 24, 2021 at 2:52 PM Derrick Stolee via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Derrick Stolee <dstolee@microsoft.com>
>
> Allow 'git merge' to operate without expanding a sparse index, at least
> not immediately. The index still will be expanded in a few cases:
>
> 1. If the merge strategy is 'recursive', then we enable
>    command_requires_full_index at the start of the merge_recursive()
>    method. We expect sparse-index users to also have the 'ort' strategy
>    enabled.
>
> 2. With the 'ort' strategy, if the merge results in a conflicted file,
>    then we expand the index before updating the working tree. The loop
>    that iterates over the worktree replaces index entries and tracks
>    'origintal_cache_nr' which can become completely wrong if the index
>    expands in the middle of the operation. This safety valve is
>    important before that loop starts. A later change will focus this
>    to only expand if we indeed have a conflict outside of the
>    sparse-checkout cone.
>
> 3. Other merge strategies are executed as a 'git merge-X' subcommand,
>    and those strategies are currently protected with the
>    'command_requires_full_index' guard.

Oh, indeed, it appears ag/merge-strategies-in-c didn't complete but
was discarded, as per the July 6 "What's cooking in git.git" email.
Well, that certainly makes things easier for you; thanks for
mentioning them in this item #3.

>
> Some test updates are required, including a mistaken 'git checkout -b'
> that did not specify the base branch, causing merges to be fast-forward
> merges.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
>  builtin/merge.c                          |  3 +++
>  merge-ort.c                              |  8 ++++++++
>  merge-recursive.c                        |  3 +++
>  t/t1092-sparse-checkout-compatibility.sh | 12 ++++++++++--
>  4 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/merge.c b/builtin/merge.c
> index 22f23990b37..926de328fbb 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -1276,6 +1276,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>         if (argc == 2 && !strcmp(argv[1], "-h"))
>                 usage_with_options(builtin_merge_usage, builtin_merge_options);
>
> +       prepare_repo_settings(the_repository);
> +       the_repository->settings.command_requires_full_index = 0;
> +
>         /*
>          * Check if we are _not_ on a detached HEAD, i.e. if there is a
>          * current branch.
> diff --git a/merge-ort.c b/merge-ort.c
> index 6eb910d6f0c..8e754b769e1 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -4058,6 +4058,14 @@ static int record_conflicted_index_entries(struct merge_options *opt)
>         if (strmap_empty(&opt->priv->conflicted))
>                 return 0;
>
> +       /*
> +        * We are in a conflicted state. These conflicts might be inside
> +        * sparse-directory entries, so expand the index preemtively.

Same typo I pointed out in v1.

> +        * Also, 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);
> +
>         /* If any entries have skip_worktree set, we'll have to check 'em out */
>         state.force = 1;
>         state.quiet = 1;
> diff --git a/merge-recursive.c b/merge-recursive.c
> index 3355d50e8ad..1f563cd6874 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -3750,6 +3750,9 @@ int merge_recursive(struct merge_options *opt,
>         assert(opt->ancestor == NULL ||
>                !strcmp(opt->ancestor, "constructed merge base"));
>
> +       prepare_repo_settings(opt->repo);
> +       opt->repo->settings.command_requires_full_index = 1;
> +
>         if (merge_start(opt, repo_get_commit_tree(opt->repo, h1)))
>                 return -1;
>         clean = merge_recursive_internal(opt, h1, h2, merge_bases, result);
> diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
> index ddc86bb4152..dc56252865c 100755
> --- a/t/t1092-sparse-checkout-compatibility.sh
> +++ b/t/t1092-sparse-checkout-compatibility.sh
> @@ -47,7 +47,7 @@ test_expect_success 'setup' '
>                 git checkout -b base &&
>                 for dir in folder1 folder2 deep
>                 do
> -                       git checkout -b update-$dir &&
> +                       git checkout -b update-$dir base &&
>                         echo "updated $dir" >$dir/a &&
>                         git commit -a -m "update $dir" || return 1
>                 done &&
> @@ -647,7 +647,15 @@ test_expect_success 'sparse-index is not expanded' '
>         echo >>sparse-index/extra.txt &&
>         ensure_not_expanded add extra.txt &&
>         echo >>sparse-index/untracked.txt &&
> -       ensure_not_expanded add .
> +       ensure_not_expanded add . &&
> +
> +       ensure_not_expanded checkout -f update-deep &&
> +       (
> +               sane_unset GIT_TEST_MERGE_ALGORITHM &&
> +               git -C sparse-index config pull.twohead ort &&
> +               ensure_not_expanded merge -m merge update-folder1 &&
> +               ensure_not_expanded merge -m merge update-folder2
> +       )
>  '

Should you use test_config rather than git config here?

More importantly, why the subshell and unsetting of
GIT_TEST_MERGE_ALGORITHM and the special worrying about pull.twohead?
Wouldn't it be simpler to just set GIT_TEST_MERGE_ALGORITHM=ort,
perhaps at the beginning of the file?

  reply	other threads:[~2021-08-27 22:43 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
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 [this message]
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-BEF0htk-Q-+wiF+XgTWRRtDc5FPJKauWZAivLGuMgWeAQ@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=me@ttaylorr.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).