From patchwork Wed Sep 8 11:23:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12480941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30BAFC433F5 for ; Wed, 8 Sep 2021 11:24:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0638661153 for ; Wed, 8 Sep 2021 11:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351424AbhIHLZN (ORCPT ); Wed, 8 Sep 2021 07:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235044AbhIHLZM (ORCPT ); Wed, 8 Sep 2021 07:25:12 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F0BC061757 for ; Wed, 8 Sep 2021 04:24:05 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 192-20020a1c04c9000000b002f7a4ab0a49so1041670wme.0 for ; Wed, 08 Sep 2021 04:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=NfMdKaRTjEVUpxzZnXjRs054AukpwAC0Z5SwjTLMFZc=; b=qFSB1RyLxqqlNoymy+Jx061B6bOpTmRY5U5Fx2YhwrUvOJm3ZGSbHU7Ncy1Vq+L1Kc 9kN4H3Kxylbwc29AnrSULPsw4CZU0SIGj8R/qMqnZplQWWCt26IFHVNYj0mATZtmYQ9+ 7Cv/uvsjKT+2y528FOFvT7DShB1JftZEkK1aCM3/gjf5Rr0B123YtrO9wx3+Qrh/Mu2T IGJt0Ee7PeL5BOK4Mgid+bh5Fe1XsfGs9dhoWrk2xnj/PXlvI3Pq0aBgW6OT7qc+43e/ 9etcIu1Z5aj4hFeGZaVktd/W28uecZWS76lI2gY+L6fsBlwCPja32u/+o/UGPNst5bVx QC5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=NfMdKaRTjEVUpxzZnXjRs054AukpwAC0Z5SwjTLMFZc=; b=n1e0mLSL+P8ZsEwTyIFJELJ4L2jknbvoF8an1OvCSVsLnY/jjqmcWTWDz4bEzZbn9p oKKhFLIn5EHiVPFYkvy8ij9Ait7R3oQJS8Gyto2y47qUiHt8g3umJYveGLFs6PEqwBgv JDS3WrK7w4TWI+Bt5jWd52S4pXhgpH7lKXGJN73E+AhXFKBIWzKtltk6tSaXz7aUXGzH ULHX80qvr/x78mw94JqPywai5qGnhzZlS37tFDWFVqL0nC/Qkt30iXce5UWwyN6GEV/p HgsUjGch5BRgXgylp1SLfQeLW7R8IDlzo7VRj5p7UhZb1AUzm3+0pTIcH2jaK70HXacC kBvA== X-Gm-Message-State: AOAM532BRpyhgr67Uc702zQw0HtEdlV+4k5jAdFW+uyV+VmM01O8KuzF qxcNLTTBUgP63iHZD49kSPWAnn9YYNg= X-Google-Smtp-Source: ABdhPJxJyHxC8mUfKFmATB8CPPbpIAc9uxZ3B8HEvQJBwabAutTyd0FQIZ0xBwzGKlKKhEgIE7sy3g== X-Received: by 2002:a05:600c:364f:: with SMTP id y15mr3030645wmq.193.1631100243726; Wed, 08 Sep 2021 04:24:03 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x11sm1860451wro.83.2021.09.08.04.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 04:24:03 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 11:23:56 +0000 Subject: [PATCH v3 1/6] diff: ignore sparse paths in diffstat Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, stolee@gmail.com, gitster@pobox.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The diff_populate_filespec() method is used to describe the diff after a merge operation is complete. In order to avoid expanding a sparse index, the reuse_worktree_file() needs to be adapted to ignore files that are outside of the sparse-checkout cone. The file names and OIDs used for this check come from the merged tree in the case of the ORT strategy, not the index, hence the ability to look into these paths without having already expanded the index. The work done by reuse_worktree_file() is only an optimization, and requires the file being on disk for it to be of any value. Thus, it is safe to exit the method early if we do not expect the file on disk. Signed-off-by: Derrick Stolee --- diff.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/diff.c b/diff.c index a8113f17070..c8f530ffdbe 100644 --- a/diff.c +++ b/diff.c @@ -26,6 +26,7 @@ #include "parse-options.h" #include "help.h" #include "promisor-remote.h" +#include "dir.h" #ifdef NO_FAST_WORKING_DIRECTORY #define FAST_WORKING_DIRECTORY 0 @@ -3907,6 +3908,13 @@ static int reuse_worktree_file(struct index_state *istate, if (!want_file && would_convert_to_git(istate, name)) return 0; + /* + * If this path does not match our sparse-checkout definition, + * then the file will not be in the working directory. + */ + if (!path_in_sparse_checkout(name, istate)) + return 0; + len = strlen(name); pos = index_name_pos(istate, name, len); if (pos < 0) From patchwork Wed Sep 8 11:23:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12480943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56256C433EF for ; Wed, 8 Sep 2021 11:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35DA761078 for ; Wed, 8 Sep 2021 11:24:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351446AbhIHLZO (ORCPT ); Wed, 8 Sep 2021 07:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351306AbhIHLZN (ORCPT ); Wed, 8 Sep 2021 07:25:13 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC99DC061575 for ; Wed, 8 Sep 2021 04:24:05 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id i28so2761871wrb.2 for ; Wed, 08 Sep 2021 04:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ZDmWBBGaLotuFCux6mhd7u56pgdwp86r+MClGOgh9fA=; b=kV+ur8WpR1KAiyzq1Tx0EoGpr1+GfqQPrXUjIXgPLWb4+EVoNDgOQhFqX29aBPl9Ad HGIkBwzcZE+2/2SsA6Ko4mQoen5FFbGh/imItwA0c33CuzKkJp1BNw0L5hy/vXm5c8b4 XqOCIeuh6h3t7iL5r2r1H86/yT0rTR0gZ+EuKWkwvlwQYGj0Ygp0jIpd2mn5eMw+rGBA PrfAb6Dwoln87SvrQg6yy2DyN2MO208F/LsF7ZxXTKkRQ1CrhN/QAOtaZRMj4bsGHA1s PjPxWsAplib+Bi7pHChgSpw5r7vhWTPKVM3pNSDWHMzskFu/zH2rEv2UI18a4JrhC3nP t7dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ZDmWBBGaLotuFCux6mhd7u56pgdwp86r+MClGOgh9fA=; b=Uwi3R7EZfUsCopwoaCiarjJf493YzNqTxpT1r73h/hHwkVafyf5A2MpEC1Lmh2toaB AN4ONHShmgeNulwn7J2w6kqNw/wk94MiiiFMOyNMTLBHIqq8sRv7H5NFcVNjW/UPsL1f OQ4GrfDHARcHQdl/2cySpBgnBjP+jRZjDLmGaxaRg8nHcj1JloVuTfpxEHOO4E1lFYgs aoACC4uLLbx6fatVZfG+kpddbSasH8Z30Nmf97EwgBEQbMkaowLWZd37azTSzVU47h/2 TPa6RsOEPF2crKRtLr7qjEHWUQ08zGLSB0hbZRm+dxeLMiKjwaFtRvrTsZT877PpUHwO Fjyw== X-Gm-Message-State: AOAM5319K+NaEguiFJAu1PawULBcDaS9I3UnHclz4ffeonxnwNchYiFL 2x2yaVB5TiKF/n0WT6XUU+g30EZuxgA= X-Google-Smtp-Source: ABdhPJzXUjfQa3eE2LhY046WUBSkkuYXkAIQgf0gFD309ZkUsTP63vDs6aWDDBKdSBSV4omnD6Y7Aw== X-Received: by 2002:a5d:5262:: with SMTP id l2mr3477009wrc.190.1631100244299; Wed, 08 Sep 2021 04:24:04 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t14sm1877553wrw.59.2021.09.08.04.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 04:24:04 -0700 (PDT) Message-Id: <141f7fb26d6aacf3d2dae7dfbc7cf1bf4fe0561d.1631100241.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 11:23:57 +0000 Subject: [PATCH v3 2/6] merge: make sparse-aware with ORT Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, stolee@gmail.com, gitster@pobox.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee 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. 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 --- 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..1531b4c94c2 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 preemptively. + * 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..3b331a6bfe7 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 && + test_config -C sparse-index pull.twohead ort && + ( + sane_unset GIT_TEST_MERGE_ALGORITHM && + ensure_not_expanded merge -m merge update-folder1 && + ensure_not_expanded merge -m merge update-folder2 + ) ' # NEEDSWORK: a sparse-checkout behaves differently from a full checkout From patchwork Wed Sep 8 11:23:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12480947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84A35C433F5 for ; Wed, 8 Sep 2021 11:24:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7B9C61078 for ; Wed, 8 Sep 2021 11:24:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351472AbhIHLZQ (ORCPT ); Wed, 8 Sep 2021 07:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235044AbhIHLZO (ORCPT ); Wed, 8 Sep 2021 07:25:14 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53235C061757 for ; Wed, 8 Sep 2021 04:24:06 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id u9so2722169wrg.8 for ; Wed, 08 Sep 2021 04:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=OA5a+Nzw5n7L/bh9CU4DUTznInpgSQyE3gZWdYHJ8dY=; b=jqmvYNdNvdvQ3s3t9lKe9pLJetKxfC7PPQYaqBQS+UDnRpmmMPQW80fLJ/R0KqfHMz UldHvgNMOvodlV1rKGHvjNVwOJDGkipuT/O4s27XMQIHAP5ID40pXBoBZA9aLIfLGB46 054EpvWzMvqEJecFr/dBjEeoMVKr+UtqHK70KrIO59TzK6572+3s+XoNHOu4Vt0L7Btf 2JQOVfH705xB5it5LKWZM9MTziHMxfmx3xhB+PunzO0/kjQgtgJkiVwA19ooCUiCr/S6 W/avU9EzJxNv1wV/4J15sv3ZqMO+RCpkfk2SV3YcCR7T0cpr68bqbKWbANYocPCbIdTs 2aQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=OA5a+Nzw5n7L/bh9CU4DUTznInpgSQyE3gZWdYHJ8dY=; b=QyBkH/vdt0TJHsY7FQidoIiPz99Cufsb2o2aM57ac/4yKko2bGeGv0S8gbHQ4Cp1bM rBP8kpQI9cZJya/XuoVUZfTEVlv9LR0R/4AIDrUOyYXynNhFhUrfCJbzgN8qtAC/9voq Pasc6/XIoeLLzmJUVJ0YAMtU42OzNtQbqVTvP940MUqymK7Ge4E2awqpDD1q1mRNltyA S0JuhY3LWBIDblbozSP/k4Eo2AbgpGsobG63TJujDr2Bc6YTLBMJiRZ4lKHR7g5wEiyx jV7Bh7ZXCuqOVbJCD7hcxmOnR4vXgi8sB8tUw5krZfnhfc8wQV7wtMc2DjyrGgwIEYQu tbLg== X-Gm-Message-State: AOAM530tmgWcLTTRlAiKA36RxDSIj3fTJgq7mwjwmlmcYqlXS95YFfF7 uCrMXDCKcwRt2hs7vlk/bYt2MnrolKE= X-Google-Smtp-Source: ABdhPJwbA/GMIUZKMyp9Qrn9wiNS3NKAd3D3uINkt1/jKv26xS5Et2SAgS8p6T0fqP+c/59QG/rpYg== X-Received: by 2002:a5d:6cc9:: with SMTP id c9mr3439181wrc.158.1631100244959; Wed, 08 Sep 2021 04:24:04 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g1sm2163891wmk.2.2021.09.08.04.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 04:24:04 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 11:23:58 +0000 Subject: [PATCH v3 3/6] merge-ort: expand only for out-of-cone conflicts Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, stolee@gmail.com, gitster@pobox.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee 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. Signed-off-by: Derrick Stolee --- merge-ort.c | 13 +++++++--- t/t1092-sparse-checkout-compatibility.sh | 30 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 1531b4c94c2..805f7c41397 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -4060,11 +4060,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 preemptively. - * 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; + } + } /* 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 3b331a6bfe7..36964f52f2f 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -617,8 +617,17 @@ 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 && + test_must_fail env \ + GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \ + git -C sparse-index "$@" || return 1 + 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 } @@ -658,6 +667,23 @@ test_expect_success 'sparse-index is not expanded' ' ) ' +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 && + + ( + sane_unset GIT_TEST_MERGE_ALGORITHM && + git -C sparse-index config pull.twohead ort && + 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' ' From patchwork Wed Sep 8 11:23:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12480945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 869CCC433FE for ; Wed, 8 Sep 2021 11:24:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65DE461157 for ; Wed, 8 Sep 2021 11:24:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351467AbhIHLZR (ORCPT ); Wed, 8 Sep 2021 07:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351462AbhIHLZO (ORCPT ); Wed, 8 Sep 2021 07:25:14 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4407C061575 for ; Wed, 8 Sep 2021 04:24:06 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id n5so2688399wro.12 for ; Wed, 08 Sep 2021 04:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=sNOF7IWMV6JpmoxZOXbwz0RZxhecQhnosCn0V8JM6KE=; b=i58ca39s9oeUrASli0KTw7SLaLOG9jabMGrF5/snYdvxuDy/hlkZ0WEzgLF69Pw4G4 l9b3nTIt5Cj8rodLgXddEDpCj++6wJAFIXn+7bQCBU73lnxjWAFHm5kDU7Fps1aFzFT8 aBFyfcWdPIVpWXs49C4JahHOfomxJO8ka4z59T6JR/4AcZfitoBBM2WWiBk1SqbnEknl KD5sLuBDh9Z7dCeJ1HXmwK3mAPS0q8g+wBYKciwa5qZ7Jna8THvBBWtfa0/jBl3egq81 9LF5L2iljqlIVni13EzjLPWy0xQOnXFWKrBILAgPxQ7w0fGY94C4BKbAkIagZ6Xgu/t8 4ifA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=sNOF7IWMV6JpmoxZOXbwz0RZxhecQhnosCn0V8JM6KE=; b=nuJi6NVFX5Z4WvGm4oUHL6ECf4GrLZ1fLoJZcR/D1IUvxx9E3GIHVLyhdeA8VgtTfR ndedokg7lC31VruKHpbFq3HSzGnwk2B1En2H7IQ9RV4PxlLOiNSP5XR6jgA+egyLlhN5 2f+IWZ2b+g1Kp567jMyhbFQHquU9S8WETzEPFTakHgFPdnWnAafXiQoSL77LBLW/cBqZ aL5K+sb2a2EJcAsOdF9SXVP+3ZJ962P5qwIYcICD/XWHxQuY/8atcCJnDKYabET+4Wmo DOVf0XHubrP0PE4ZXUQJjyddPyISWk4XUa0ky2HClz8OEPMPtDPLaEUiKnL5bOlP7Fji Lqfw== X-Gm-Message-State: AOAM533ovlzmL2YC1DX3sac485SPv3CGuOChWi5xe527RzmFDFMYr/Yr 1zD0elcVVJ259PMlsfLEDASDq2yv09Y= X-Google-Smtp-Source: ABdhPJwQRh8cOkg2G2uHXvkCidLWDzVfCOVCMC/nj1nJqEzGUhVMnwyuIqRYEed9cwU8ZRf2ke2Vtw== X-Received: by 2002:adf:c501:: with SMTP id q1mr3536309wrf.150.1631100245549; Wed, 08 Sep 2021 04:24:05 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n4sm2110198wro.81.2021.09.08.04.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 04:24:05 -0700 (PDT) Message-Id: <7aae5727fb79620ac9e0dac201701fe15fb579ab.1631100241.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 11:23:59 +0000 Subject: [PATCH v3 4/6] t1092: add cherry-pick, rebase tests Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, stolee@gmail.com, gitster@pobox.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Add tests to check that cherry-pick and rebase behave the same in the sparse-index case as in the full index cases. These tests are agnostic to GIT_TEST_MERGE_ALGORITHM, so a full CI test suite will check both the 'ort' and 'recursive' strategies on this test. Signed-off-by: Derrick Stolee --- t/t1092-sparse-checkout-compatibility.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 36964f52f2f..d9424ed6427 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -481,14 +481,17 @@ test_expect_success 'checkout and reset (mixed) [sparse]' ' test_sparse_match git reset update-folder2 ' -test_expect_success 'merge' ' +test_expect_success 'merge, cherry-pick, and rebase' ' init_repos && - test_all_match git checkout -b merge update-deep && - test_all_match git merge -m "folder1" update-folder1 && - test_all_match git rev-parse HEAD^{tree} && - test_all_match git merge -m "folder2" update-folder2 && - test_all_match git rev-parse HEAD^{tree} + for OPERATION in "merge -m merge" cherry-pick rebase + do + test_all_match git checkout -B temp update-deep && + test_all_match git $OPERATION update-folder1 && + test_all_match git rev-parse HEAD^{tree} && + test_all_match git $OPERATION update-folder2 && + test_all_match git rev-parse HEAD^{tree} || return 1 + done ' # NEEDSWORK: This test is documenting current behavior, but that From patchwork Wed Sep 8 11:24:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12480951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3C9DC4332F for ; Wed, 8 Sep 2021 11:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97A5E61157 for ; Wed, 8 Sep 2021 11:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351479AbhIHLZR (ORCPT ); Wed, 8 Sep 2021 07:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351306AbhIHLZP (ORCPT ); Wed, 8 Sep 2021 07:25:15 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC36C061575 for ; Wed, 8 Sep 2021 04:24:07 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id v10so2745610wrd.4 for ; Wed, 08 Sep 2021 04:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=TW6UFTzZ+QULGGc8KN5tLIiTgHZXppX2ImGqtUqI5sQ=; b=INGovI4/xcEWUoyaPcaObXYGCHgdiCdTROa2fH+OjG9GbmZvA5aMpfA15cLu8NPxhY VXZ4x5R46dCgbxhjT/wt4lI4UoMcyz73LzGs0/rvKeh4Eb3liv+q2l06r5CxIxEndKMd Lx3JkGE1e3VF1j6PCI66ZbrPlTyzyIOpfxiSfBEDqz5hwW50+1Rt/PLFDP9HjfFOTwUA 2AWslLxpnDlHR/CGZRsvsLvFAcxExBGi2Sd7d4mM4oRWya4NZ6RjwLt4bbqrtBUK1H6w jkil/3EZnUGrdqKpAXJOHtkM00KdrYoWTOvMzEC+BJQRahUmQ1edc0B25Zp5NwePBSid 6v6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=TW6UFTzZ+QULGGc8KN5tLIiTgHZXppX2ImGqtUqI5sQ=; b=tIlo4F+QVEOZB756hoTFEKOM6Sq1qPH5Vifa9HiDbLXf+ILiiALif7Taar+mVmGQuG wGSZ+AG5wQaYOkKQJoFd+Tuzy9+e71ywZpUbOgPl4vSfQ7JSCR2KnBdLp9p8MR4fZ6E9 KmfM+V294Bn+Hx14/SRAv0fwO17NHboBwF+yscxdyaYrtwkHznzdFn8O7GxLoDQGmNaE 5ixIU42TK2vcjwnJqc25keCHJCCtN1zeim997Cbyo0hHuueFMaIwW11W/ufcjk2Nq+5Q riX5bJe+7ZwjFqxy14yHych/fgom880PhII1NS+v3ImLwXzf7sh8Luh5+Z2vhdv1MMAI ulyg== X-Gm-Message-State: AOAM5334DpmLnGrsv3h4IkaMoff+mf1SN/nHrwrGLBBxOBdgj4myb3VZ pjTyM3E7XkbHKp0tw/NIAyqm9lJlWrc= X-Google-Smtp-Source: ABdhPJwkg9v5HnNjcbRDUeyI6tmO6QzYYimcleOZo0qsi5A4sruC6LHJLpH2j3t/4cRHqK0I6q1ACQ== X-Received: by 2002:adf:f84d:: with SMTP id d13mr3535297wrq.292.1631100246145; Wed, 08 Sep 2021 04:24:06 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z6sm1814676wmp.1.2021.09.08.04.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 04:24:05 -0700 (PDT) Message-Id: <20f5bbae5463cde26505f49bbcf80fdeeb9f65f4.1631100241.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 11:24:00 +0000 Subject: [PATCH v3 5/6] sequencer: ensure full index if not ORT strategy Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, stolee@gmail.com, gitster@pobox.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The sequencer is used by 'cherry-pick' and 'rebase' to sequence a list of operations that modify the index. Since we intend to remove the need for 'command_requires_full_index', we need to ensure the sparse index is expanded every time it is written to disk between these steps. That is, unless the merge strategy is 'ort' where the index can remain sparse throughout. There are two main places to be extra careful about a full index: 1. Right before calling merge_trees(), ensure the index is full. This happens within an 'else' where the 'if' block checks if the 'ort' strategy is selected. 2. During read_and_refresh_cache(), the index might be written to disk and converted to sparse in the process. Ensure it expands back to full afterwards by checking if the strategy is _not_ 'ort'. This 'if' statement is the logical negation of the 'if' in item (1). Signed-off-by: Derrick Stolee --- sequencer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sequencer.c b/sequencer.c index 7f07cd00f3f..228bc089d22 100644 --- a/sequencer.c +++ b/sequencer.c @@ -652,6 +652,7 @@ static int do_recursive_merge(struct repository *r, merge_switch_to_result(&o, head_tree, &result, 1, show_output); clean = result.clean; } else { + ensure_full_index(r->index); clean = merge_trees(&o, head_tree, next_tree, base_tree); if (is_rebase_i(opts) && clean <= 0) fputs(o.obuf.buf, stdout); @@ -2346,6 +2347,7 @@ static int read_and_refresh_cache(struct repository *r, _(action_name(opts))); } refresh_index(r->index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL); + if (index_fd >= 0) { if (write_locked_index(r->index, &index_lock, COMMIT_LOCK | SKIP_IF_UNCHANGED)) { @@ -2353,6 +2355,13 @@ static int read_and_refresh_cache(struct repository *r, _(action_name(opts))); } } + + /* + * If we are resolving merges in any way other than "ort", then + * expand the sparse index. + */ + if (opts->strategy && strcmp(opts->strategy, "ort")) + ensure_full_index(r->index); return 0; } From patchwork Wed Sep 8 11:24:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12480949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1947EC433EF for ; Wed, 8 Sep 2021 11:24:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E955E61153 for ; Wed, 8 Sep 2021 11:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351473AbhIHLZT (ORCPT ); Wed, 8 Sep 2021 07:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351468AbhIHLZQ (ORCPT ); Wed, 8 Sep 2021 07:25:16 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39717C061757 for ; Wed, 8 Sep 2021 04:24:08 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id d6so2697392wrc.11 for ; Wed, 08 Sep 2021 04:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=NhVGodYegspo2WMnVFa4iDfSwEgWB/VRcImjAbZjlZ4=; b=AyJ512aG3UG3YfCfYigumXuBBqvouVA1pu5UylyOKb/JejBU0WHu7C6uvICqULBhEb qcUTSaPEUWx8Tb89RP83BcZ43PHUqYthE+5y+TTQ475enqiCyyAIjrgBGTkvYHVFsvdA X9vQp4jSygAOtfJwaSwi6yQUKB3RqPxiO1ReNJAuSIb3BdFBmMu1FVGR9hFQZk5uwxvJ 3GSoTf1sJZiSHqbSoH1jgEXTI3Scd8QqkpVZAE9++DcqG4fUB6W2woJQBz+m7LIL5+eK RJQMSFV6ErT+ZD451x+rhwQ58jQKO8EQgigY6Bsj0rbBtiQ6BtLevKINV20GpO2TDeOD BpQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=NhVGodYegspo2WMnVFa4iDfSwEgWB/VRcImjAbZjlZ4=; b=wlH/ggoY19OeRiUP0E+iP3i7Kpg+0R4IJ3og0V9L8yECIvduA9PhyZ8M7Jh2lL6Gyr nvMSBrxScr7+BnbXzs2DSod758+fzILK50bNQaCVuOe5RJOga0ukFiTHpt1eTdoDrCfJ zJQqkfA9DIQKVedF+Iq8mJwuERftO429Z84olO6+w4jDO7VMRGMYINXyMiqkNAv2li2R EYKR8rHet3NH4W5+71hvjy9U9SavuuvSNl+bbUh/BkcNSpmiVZTE44oXMd/lDxCzde6o kX/Cx6TKLHOspzE+3TYUphi1Ko18j8TK7JhzW9BM5EJpzWJxfTEFhWPedn2R2EAxzPh3 RFAQ== X-Gm-Message-State: AOAM533FkfRwIqJ6ye9Thdgoeahrd1n/m4HPnFP4TuA6jEALMozQom2n Fg2lcs8wlbtlu3YSiZCjnV95ouormMc= X-Google-Smtp-Source: ABdhPJyaM7H/N23C68m4T28sUU5+MmQOtM7+PjC7bOyvTcdHYL7jDKV13pCU6kpzdFLd+6QWYdtFrg== X-Received: by 2002:adf:de09:: with SMTP id b9mr3447644wrm.114.1631100246834; Wed, 08 Sep 2021 04:24:06 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n1sm1838028wrp.49.2021.09.08.04.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 04:24:06 -0700 (PDT) Message-Id: <36cecb22330dd52191e810a828eccbe098c48827.1631100241.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 11:24:01 +0000 Subject: [PATCH v3 6/6] sparse-index: integrate with cherry-pick and rebase Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, stolee@gmail.com, gitster@pobox.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The hard work was already done with 'git merge' and the ORT strategy. Just add extra tests to see that we get the expected results in the non-conflict cases. Signed-off-by: Derrick Stolee --- builtin/rebase.c | 6 ++++ builtin/revert.c | 3 ++ t/t1092-sparse-checkout-compatibility.sh | 39 ++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 33e09619005..27433d7c5a2 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -559,6 +559,9 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0); + prepare_repo_settings(the_repository); + the_repository->settings.command_requires_full_index = 0; + if (!is_null_oid(&squash_onto)) opts.squash_onto = &squash_onto; @@ -1430,6 +1433,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) usage_with_options(builtin_rebase_usage, builtin_rebase_options); + prepare_repo_settings(the_repository); + the_repository->settings.command_requires_full_index = 0; + options.allow_empty_message = 1; git_config(rebase_config, &options); /* options.gpg_sign_opt will be either "-S" or NULL */ diff --git a/builtin/revert.c b/builtin/revert.c index 237f2f18d4c..6c4c22691bd 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -136,6 +136,9 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN); + prepare_repo_settings(the_repository); + the_repository->settings.command_requires_full_index = 0; + /* implies allow_empty */ if (opts->keep_redundant_commits) opts->allow_empty = 1; diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index d9424ed6427..886e78715fe 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -527,6 +527,38 @@ test_expect_success 'merge with conflict outside cone' ' test_all_match git rev-parse HEAD^{tree} ' +test_expect_success 'cherry-pick/rebase with conflict outside cone' ' + init_repos && + + for OPERATION in cherry-pick rebase + do + test_all_match git checkout -B tip && + test_all_match git reset --hard merge-left && + test_all_match git status --porcelain=v2 && + test_all_match test_must_fail git $OPERATION merge-right && + test_all_match git status --porcelain=v2 && + + # Resolve the conflict in different ways: + # 1. Revert to the base + test_all_match git checkout base -- deep/deeper2/a && + test_all_match git status --porcelain=v2 && + + # 2. Add the file with conflict markers + test_all_match git add folder1/a && + test_all_match git status --porcelain=v2 && + + # 3. Rename the file to another sparse filename and + # accept conflict markers as resolved content. + run_on_all mv folder2/a folder2/z && + test_all_match git add folder2 && + test_all_match git status --porcelain=v2 && + + test_all_match git $OPERATION --continue && + test_all_match git status --porcelain=v2 && + test_all_match git rev-parse HEAD^{tree} || return 1 + done +' + test_expect_success 'merge with outside renames' ' init_repos && @@ -665,8 +697,11 @@ test_expect_success 'sparse-index is not expanded' ' test_config -C sparse-index pull.twohead ort && ( sane_unset GIT_TEST_MERGE_ALGORITHM && - ensure_not_expanded merge -m merge update-folder1 && - ensure_not_expanded merge -m merge update-folder2 + for OPERATION in "merge -m merge" cherry-pick rebase + do + ensure_not_expanded merge -m merge update-folder1 && + ensure_not_expanded merge -m merge update-folder2 || return 1 + done ) '