From patchwork Tue Aug 24 21:52:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12455959 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 74EDEC4338F for ; Tue, 24 Aug 2021 21:53:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6044A613B1 for ; Tue, 24 Aug 2021 21:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237379AbhHXVx5 (ORCPT ); Tue, 24 Aug 2021 17:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236380AbhHXVxd (ORCPT ); Tue, 24 Aug 2021 17:53:33 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E41C5C0613D9 for ; Tue, 24 Aug 2021 14:52:48 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id c8-20020a7bc008000000b002e6e462e95fso2857267wmb.2 for ; Tue, 24 Aug 2021 14:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=NfMdKaRTjEVUpxzZnXjRs054AukpwAC0Z5SwjTLMFZc=; b=O11HuEymHPhs9SfCLRLC/iqwyOSm68RZ69Mm6Cnx4fiIvyh7OFORt8odQDUWIZxryY 5Nqmd7P1PjJgoVjCOWobxrd6WU6ZN5Rqen6My+fxMrW++diM5pUhLhhFENiHne0Z4VPq /TfYlRqnbvMe36Huc/o5gEp3bJTRjl0FEM4dWHWQ0L+QKqiYhLPyJPqPCrPeHCF8yEBX DjYpdhHD1UG2vAWDEnG/PNKbkAbdsFaUzq3f6GyyIhiswaMzq146mZJifF1Yx31q1RSM VzPp0BO63BwDWhcUtW30iQiaOiGFR45O+ZMpKsxl8gmmIRo+nNkJxGYaJdcqhlW4yskx vcRg== 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=YqiBRs3Fl+K0fbGbAj67iOqrNAm+2WOReAPg6D6e1TNDvSdU8NdbCTF8YysJ6abSIF IXbnDhpEM46ED87yv7KRD/ysrs6d/CYN2UHh6XyjvFXX6SUZRrRckbn+w8igjbRtjwvJ pjsfpTRmXLsZR4bhbCDdX1GNNCipBWt/FkM60OUGxCV3kMvm3dlnqQTcaRWrkw4S05Vc lL5LqCKhzpSAay9ZXT3aVB1CjAycB3byB99YpH8damP2UurS8JaHnakjLYUqm4hdIPwm NOQERjH+BFRkb8g9THNXNMjk2o/ldK12gj9R9dAa3IT7dco68pPknVvRekz/jaP4q5yd gf2Q== X-Gm-Message-State: AOAM533Z5nLmS5KGRp19qxOw+wn0Rz7HLrzJx0007/AUKe7npIEqsB9S frD6m0WzjkMFytTenRYb3WZe60yZFOE= X-Google-Smtp-Source: ABdhPJwBwop58PIv8xPipbsed34y0pFOqyhvOY3Yp+gRaDeZyWjPQ2NGUoqWvGZr6/sbPdsNW57z/A== X-Received: by 2002:a7b:c30f:: with SMTP id k15mr6048010wmj.128.1629841967614; Tue, 24 Aug 2021 14:52:47 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a77sm3619117wmd.31.2021.08.24.14.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 14:52:47 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 24 Aug 2021 21:52:40 +0000 Subject: [PATCH v2 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 Tue Aug 24 21:52:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12455955 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,URIBL_BLOCKED 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 2B466C4338F for ; Tue, 24 Aug 2021 21:53:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00AB36138B for ; Tue, 24 Aug 2021 21:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235895AbhHXVxz (ORCPT ); Tue, 24 Aug 2021 17:53:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236513AbhHXVxe (ORCPT ); Tue, 24 Aug 2021 17:53:34 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8335AC061796 for ; Tue, 24 Aug 2021 14:52:49 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id i6so9605456wrv.2 for ; Tue, 24 Aug 2021 14:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=EanV4q9h6+26esLEkg3TaW0nVQ2fALRpqsJISy3dnr0=; b=YwN5NwLEf2JEiM2JjUxhy2njex41rlR3hXZww2w+t9FSvI4LOg9fFfU4kFUxphyQO3 kmUF0c5Z5L1JLuzcKmPFYYlrG1H6RSp0d8FaTvlkD9gsA1is3bdOxeNgboe4oG1/AmR6 56N/b7pybA+d/V/14qWrMZvBwVj5feYBJSSpxGN9sAdeQMpmHppsk0wGoYwMZEbCmat4 FZqdIRtJqUF5a8vS/Oc3EVhell67sg3zyMOvjnjugB6ZDVF31hTeQBc6tFR7nz1FDmSJ Xjcr6UQ0BCatXgEIYGYAh4IabDXtf49k8XCT12wHZtt31amSmrqPgWKGf/qjKSCtBHCa K1CQ== 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=EanV4q9h6+26esLEkg3TaW0nVQ2fALRpqsJISy3dnr0=; b=P/VOAWbBtfs5usuPQJX0W/HL1ximtSI2LuXjd77lvoIFkda3S1hqBzPjnWR+Ipetme xKCsc9HgwgbSly702hpGDKypnt07EqZYqifLsAPpuwPJe4uM/7GarvjA4pb2lye/vmas 698bjKsmSKqEB4DXyNXinkOsXEIse9Kug1+/6hDXxHwpmZqrU3F2qU3ecaowMry+3Ft0 UMBz1gDp/QNGwZujrcT85/10RHy9PdKiceXdffR0zONohDD6UzknR8PZvr1jjqgl7KEQ o2eDaLA+fGQq1xifNdqaX367KjY07Zn0L8B1jWN7q/jc/NtaYRUSZWeI2HUvkxiUhUjR 7EdA== X-Gm-Message-State: AOAM5336nxnfsfgGxzrpJYNvHyhUrvPoYZjb0aYOmNftjFk5vuDTsrl8 T4tcasJpajydG8YdszdqFVfNvtgcTOM= X-Google-Smtp-Source: ABdhPJzaWBAoNvaoxs+dqRRT9BrDqhOcYoWQn3WF9xuAOqwO9aE0Q9v1lqh2OzOSvOPfNj9CR0o7kQ== X-Received: by 2002:a5d:590b:: with SMTP id v11mr16447901wrd.125.1629841968191; Tue, 24 Aug 2021 14:52:48 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l2sm3475222wme.28.2021.08.24.14.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 14:52:47 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 24 Aug 2021 21:52:41 +0000 Subject: [PATCH v2 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..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. + * 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 + ) ' # NEEDSWORK: a sparse-checkout behaves differently from a full checkout From patchwork Tue Aug 24 21:52:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12455961 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,URIBL_BLOCKED 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 DDAE4C43214 for ; Tue, 24 Aug 2021 21:53:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C649C613CD for ; Tue, 24 Aug 2021 21:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237830AbhHXVx7 (ORCPT ); Tue, 24 Aug 2021 17:53:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236525AbhHXVxe (ORCPT ); Tue, 24 Aug 2021 17:53:34 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA15C06179A for ; Tue, 24 Aug 2021 14:52:50 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id g138so13674033wmg.4 for ; Tue, 24 Aug 2021 14:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=G6KS/UZhmVfAyMCKj43H7GZHhnWEANZJctnnUaSeytA=; b=iQCKiQLe5qiBhOdu1JcIuN0a7tNPUyxZB+xAJL2brhO04RxqNRDe1cGJxuVX2CSlYH YXszCdUB9yVwBLPzJakx4hmjVaF+5Aglshbk9k+Yw7fdc4CIspzDJ+kcaV9gTJ90H1bb NgkOa0/ORK9LYa7fcaLaXJsFU1cwENZsF3HTqhbD8X0DFBOf1h3tzZbWp6WIrA0kESCE PvXBVItIF/sCl6mCyiv5vN5BlZyAw/+4TKOubAUNoiRI67ERmVPtE+o3AHkaSipLx+TZ Q8PKnofG3clVsjdwaqbJtMZ+pskFTNWQBkElwCYAPSybZVmVRnAU7QPk4+3qQjZAMq61 apAw== 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=G6KS/UZhmVfAyMCKj43H7GZHhnWEANZJctnnUaSeytA=; b=CH+FZpgWO7o/67BOe7bFm45FqFm7fdje0NwZUPkl1RQO4XXYtQjNLMxS4CYr3k2XrW uIOF2KTWXNFiUYVp2+SMDVFxxDo6s6w1dloegPeagaQsCXsGaqdnsoleqYr1NKJKSYOR +BjkYtWXkPr5N3HWkNFivwOxy7K+6uteej3osyEpOfdzGvcbX2KVw6Hr4EyAQDpDNrPL fxerXHSofhNIcrRf47ejZZ2bXK3pjX4tQDgpnDypvUBpUzKsMwAjfYldHv2f9orcEekN WGllJY6i1pmCHQtsT04uIjWF8yteWfQPwsu4nxdOVplHrvn8G85SirT4gyUU2htSlpiH lR0Q== X-Gm-Message-State: AOAM531HpV/Qac6BSyxVBb1YgF/GobjSANtcaqRCmg3CXq9JR+vPXz1A Z484dDse1pEPZ/wIj4Ny/aNg+CcBMaI= X-Google-Smtp-Source: ABdhPJwu+Q9eNJAgYR0mDAt0QKmvL51d5z1nPvQY8a6dQeIFbuCR5H609DMfxL1G/aq27FQis0VXlA== X-Received: by 2002:a05:600c:4ba3:: with SMTP id e35mr6017652wmp.130.1629841968765; Tue, 24 Aug 2021 14:52:48 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k13sm3156883wms.33.2021.08.24.14.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 14:52:48 -0700 (PDT) Message-Id: <815b1b1cfbfedae7ccbec51b382053e3dcf197de.1629841966.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 24 Aug 2021 21:52:42 +0000 Subject: [PATCH v2 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 8e754b769e1..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 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; + } + } /* 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 dc56252865c..38afdf689a2 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 Tue Aug 24 21:52:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12455963 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,URIBL_BLOCKED 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 01B55C4338F for ; Tue, 24 Aug 2021 21:53:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAD21613CD for ; Tue, 24 Aug 2021 21:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237829AbhHXVyB (ORCPT ); Tue, 24 Aug 2021 17:54:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236719AbhHXVxf (ORCPT ); Tue, 24 Aug 2021 17:53:35 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA08CC0617A8 for ; Tue, 24 Aug 2021 14:52:50 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id h4so3170317wro.7 for ; Tue, 24 Aug 2021 14:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=nr451am8hUX80HW6CptFuPbQfrGQFS6G9xt954TY6Qk=; b=dtlD4XCHa1YddpqJqvLRDhZ04L18MHTL55GzYqkIlYq5/+/BOd7WHXMBjsVA3AV38r YH1XR7xNXytHOjGjVEr4ae0hkpmNMaJ58GK5q7ArqSTfK//qlSvNnGJPl7gIN1rTrp6s APG6aCtTVyYhcpJicHsGMc2MyUNB8Jox6m+7153lrfhNX9oquOhtcubqU/69GBqvDbw6 VEJ5/gh5MnnfqD3kSy65hXrBhjLlNoyCVSCuUKYIDHebX8wIqyKP+BIfTbUVHIJWLBF9 J1DLjnG+SVhO4zz4zd/A1PoJUM+WojuqS5CZXMOUNkUzsF+VOBiadY/FH3ibCMS2SdAF VQzA== 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=nr451am8hUX80HW6CptFuPbQfrGQFS6G9xt954TY6Qk=; b=EBFSesSF4r7yTaE+1idBdcJRa1vKjXQT62Htxsm5ZnTl1GjVzwTDPabdfM77fQEdso MYiXKPsnhjDvcamLsnDw9rKwSHszqUlPUzpONxMH0BzsmZXiTlOahypcwolFvm4FMgii VU/DvIb1ocW1zsmavSJyIXQPchFQhp+lLR9wgAC1aX13nwUVRMs2IVYnzU+l0dbXKE2+ zDxXHIH/DgOIB3tHhajo1kxnxszG+PREh6ybTMx2cYlDiWc8JOhGuXoCKQPUs4A8Ah8i fYHm5uv9Rrvn/aCGsR4sAVHrnXfd4EYoQfF9qbQsruAXSsZ9rIUQrhSnpQLMgTiPOXXD pqTg== X-Gm-Message-State: AOAM533NxiJABUY/wdAPVtJPacTGUAcLubyAr6GKdKup8rGxELZe4aL9 JiZmb1VL4C+6uw5jjJqSfd7SjncqRnc= X-Google-Smtp-Source: ABdhPJwsPxXPlkbYrfVvCF+TMGoFzof+byyNwll9vwPOYc2lO8qkMMcNhwul3sjUFNZU1tkNpniT6g== X-Received: by 2002:adf:fc43:: with SMTP id e3mr21381396wrs.328.1629841969403; Tue, 24 Aug 2021 14:52:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h6sm3998582wmq.5.2021.08.24.14.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 14:52:49 -0700 (PDT) Message-Id: <8032154bc8a1da17e6793ba0322d892760a11c8e.1629841966.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 24 Aug 2021 21:52:43 +0000 Subject: [PATCH v2 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 38afdf689a2..60d7400d014 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 Tue Aug 24 21:52:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12455965 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 60D59C432BE for ; Tue, 24 Aug 2021 21:53:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44B84613B1 for ; Tue, 24 Aug 2021 21:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238066AbhHXVyC (ORCPT ); Tue, 24 Aug 2021 17:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236854AbhHXVxg (ORCPT ); Tue, 24 Aug 2021 17:53:36 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F46EC0617AD for ; Tue, 24 Aug 2021 14:52:51 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id x12so33319491wrr.11 for ; Tue, 24 Aug 2021 14:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=TW6UFTzZ+QULGGc8KN5tLIiTgHZXppX2ImGqtUqI5sQ=; b=BtojbLJMna2sw9Sy3puGliRicfg2kB0t99dFEGUu2AMjJyMPfXAw7wmveE3Gn/TMRR 4QnYxBiGcZQDnH/k5LtRDKOa6hMyAeXZs3SbbxmVIJNA3hOFUPcWciqFYOC8FbZ3l5Tp NPefoasBzkYVC11sb3Kl773HjanTYk6Pguj+RQN0VKua/exrpAOyF4mflFWi4tfwLrMT iKwT8682dmeFib30HhdkBB+pntLqma2SAS+3deN58rvFdBPQR9CWgtAR+vVYkIa/E5MZ iSi9guXTLQhfbXYwkRTf9PoacU2+xGQBxYDUNSlPmYrrPXUMXtqsfnTbbJXMSaYaTZLN a9Jw== 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=TW6UFTzZ+QULGGc8KN5tLIiTgHZXppX2ImGqtUqI5sQ=; b=r8NsTLw+Ts0mv/TMDM0uHW/mMCOFP/Wnl8lCmKEXjnbSed+O5Wyhs/ezTB16hQPAe/ /v6n62jAQeQNwb509X+Lb1u9hxbb7zmX1aefjWjNFEyHUugxRiPVFDLu3Y1G2Y6TP71M +nmXpNjD95HePyxmU2xerjh0RgUfLeFfSG6ZA/kO9fzFj85yOOYfqUP9F9LfTey1Kn7H //JYD/+RHBMFqHPsudfff0r5pUE7eqGGZXs5anObcGtU+vQYwG65xXa63C3POhsYe5Tb OLnrYl8n95cjyk9cow6I8wD0b33tzsKS0sla//fZxBGMwfAlKIK6RheX2qCTFGqunn3N vOFQ== X-Gm-Message-State: AOAM532Zk7gmqZUnFuUHEfFjogjmOj9D+7Q9XDhI4qk6FD1P/QWvbEvk YrLkgUoqwhI8Zh23jfyAeV5Gmmz6iQM= X-Google-Smtp-Source: ABdhPJzRDeokGk1fMTUtz2InsFTFBQEHuj9fJ/Q6Ir6r6z1V5ZyAAejAZwKu/7ix1CFjip9FlnGw5A== X-Received: by 2002:adf:8102:: with SMTP id 2mr20764229wrm.89.1629841969924; Tue, 24 Aug 2021 14:52:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h6sm3998610wmq.5.2021.08.24.14.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 14:52:49 -0700 (PDT) Message-Id: <90ac85500b822601dd6283bb1fd04406b0e2e461.1629841966.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 24 Aug 2021 21:52:44 +0000 Subject: [PATCH v2 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 Tue Aug 24 21:52:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12455967 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,URIBL_BLOCKED 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 678BAC4338F for ; Tue, 24 Aug 2021 21:53:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52149611C8 for ; Tue, 24 Aug 2021 21:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237833AbhHXVyD (ORCPT ); Tue, 24 Aug 2021 17:54:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236966AbhHXVxg (ORCPT ); Tue, 24 Aug 2021 17:53:36 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C426CC0617AE for ; Tue, 24 Aug 2021 14:52:51 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id e5so16779110wrp.8 for ; Tue, 24 Aug 2021 14:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3oiI703uZHfsbLGPVj5VdwMJxHrMiU10UfZYn2zc1t4=; b=LlWfiJP93QHgmB7B4e0MTRXLR6pzRCgRgoCbrBOW/af6bwfJjPsunwDrB8ffo1HBEL 2KV3SmziIP45fZUyHO6cKyJfMWFn2tzcP6xvaG0qSBPCXwLVPq+USiNJq2c8gN+5LWMJ wQ/EaG2osUudF6OCRlq2CJ1gmRcPLJ5X6fz8J0KtUBnqCeWToeXlnSB2c9NocRj4N4/S yU9QJPZ7T6/P1UJROdz65KAfwg33qKhteoR9B9xaJTjQAta1Qh8ys4a1ABZuqFJJal+u Fvq8RXuun9uvBlrGetAh/F910WDUPfRBAmSLXljt7UpKxDD8AkeSSLLlZdw5oaXBhnUb wejA== 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=3oiI703uZHfsbLGPVj5VdwMJxHrMiU10UfZYn2zc1t4=; b=NL/OAxpxjhY8LogsclgI1FtnaX7F9avV3wpY78XAxNEfEjwJaA9VQhMvwLTB43Jtmu wCp+Trvr7UG38DIrPZ7clsXONpgR7aJQLZgjZ1r0OPZV5cTvdAyhf1MYpb+65U5wzamQ InaQfnbCEB54GC+oOB5bDb0icZ5s4BQI2li+0csP4N+Dql/gzVihjtI1tn+TImo6tP5m z5nT8vPsd7hC+lZ/bGk4ul3wDGUp5uyK3c0oK3XT3gfL1QidwpJICuMGR1xrVoa8Q2vg rt4Uqq1EhE+Jcy2R0Cu9iRQrFy5Qw0v8X6vvhGSQ21w5Q7NT25AWrzJQFm0u/kFMtn08 gVgg== X-Gm-Message-State: AOAM531b4bhslJg6pvRb3A3+u/Gsvlj+i8QGPcz2x8xcCBnYckR/VFzy l9LU6hw5BnUM4XXqYlNl58tIVJTz3Aw= X-Google-Smtp-Source: ABdhPJxGC7aNCFyGwEIuqtOCA/mNsaXQ1reyQs3z3z4FevcDeYJmUkNOknQVDFBqex2UXJd2MeKLZA== X-Received: by 2002:adf:f889:: with SMTP id u9mr10744520wrp.67.1629841970477; Tue, 24 Aug 2021 14:52:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d4sm20091627wrc.34.2021.08.24.14.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 14:52:50 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 24 Aug 2021 21:52:45 +0000 Subject: [PATCH v2 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 60d7400d014..bbc6de712c4 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' ' ( 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 + 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 ) '