From patchwork Tue Aug 17 17:08:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12441781 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 3F7E5C4338F for ; Tue, 17 Aug 2021 17:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C2A660FD9 for ; Tue, 17 Aug 2021 17:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbhHQRJY (ORCPT ); Tue, 17 Aug 2021 13:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbhHQRJV (ORCPT ); Tue, 17 Aug 2021 13:09:21 -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 92A7FC0613C1 for ; Tue, 17 Aug 2021 10:08:47 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id q10so29725844wro.2 for ; Tue, 17 Aug 2021 10:08:47 -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=EFox4U+F6W40H0/eDGnPhGlIzsTg6u9PPbEaj/R3UH0=; b=gYHusIUOgNXb8QBFipQT3twQUto7q/PUOY7+WRSMYIW/C5ilXvYpY/cp/mN8vVJVtc 1JpbN0dRwZJQv1LkRy4LdqKcH6eD31gkaQ8EPzFsq73IidwO7+sz6ylGG5Z7W0j+dWce QW57zcbGIng5E0Q9ItK+yrbO6mR2vaxUwb4kGrODU4iKGZ28oOOoBxq/DZeucKKAW5el LzJn+HZ45Jj9ZNOFiFRZcoZtudcq8lNCk8ceKCSLaJQWc/EETRtBXptNKPpWJF//vC5+ 1UXx98Epn5tkXLMpNjbnACPf4m4W8Mrpqr4X9QOEuPQ/DnFdoHAASQMP1ya8Jo3ekUW8 sK8w== 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=EFox4U+F6W40H0/eDGnPhGlIzsTg6u9PPbEaj/R3UH0=; b=Awi1Zx6GsNk1FWo3f2laRAHxi8x6+QWtZNdxSps/L0WYPYceBFaWnAIJlyGM7MJF5h +oS2M8AjnYrrYRc0UmpkZ9wgdg8jicjBAImQUmok/C4kXxPIF4Fz6zl3Azctq6+n5YQ3 tu9AdN+aDkYtQvXVvXGIblN3lvPC0IQutQ8Nd7jcGoW2aFcPjhfw7polWsmxyudJh9cU YQl8l+tea6zWpYX0a16P1o8AkrCVLQLcndyoKFfVdHWmTbbAyBsTSg7Q/QJPPZS62Xon CnpcTHUhf99dVfxamTYcjvfuPWQmBundnYYICkeEGreUnJ42D7yNR/l6svR52pc5DocB T0Ww== X-Gm-Message-State: AOAM530tchMSbYMQSZ9yByNj89LEmODUBkb5aZeui1x4APgez/pW51XN YL3fknx71rPs8dmhXVds+6qlhe+LmCE= X-Google-Smtp-Source: ABdhPJxQIw9q7eSqsFEnXHChPQ7NcYBBLSAwoo0iwdvsIbVlkv6EV3y4iIrk2otqkCaWsQZIdlCjaQ== X-Received: by 2002:adf:f40d:: with SMTP id g13mr5460357wro.69.1629220126277; Tue, 17 Aug 2021 10:08:46 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id e6sm3214745wrx.87.2021.08.17.10.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 10:08:46 -0700 (PDT) Message-Id: <7cad9eee90bcee3cb98be5c7a2edaca5e855c157.1629220124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 17 Aug 2021 17:08:39 +0000 Subject: [PATCH 1/6] t1092: use ORT merge strategy Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, stolee@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The sparse index will be compatible with the ORT merge strategy, so let's use it explicitly in our tests. Signed-off-by: Derrick Stolee --- t/t1092-sparse-checkout-compatibility.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index ddc86bb4152..3e01e70fa0b 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -7,6 +7,11 @@ GIT_TEST_SPARSE_INDEX= . ./test-lib.sh +# Force the use of the ORT merge algorithm until testing with the +# recursive strategy. We expect ORT to be used with sparse-index. +GIT_TEST_MERGE_ALGORITHM=ort +export GIT_TEST_MERGE_ALGORITHM + test_expect_success 'setup' ' git init initial-repo && ( @@ -501,7 +506,7 @@ test_expect_success 'merge with conflict outside cone' ' test_all_match git checkout -b merge-tip merge-left && test_all_match git status --porcelain=v2 && - test_all_match test_must_fail git merge -m merge merge-right && + test_all_match test_must_fail git merge -sort -m merge merge-right && test_all_match git status --porcelain=v2 && # Resolve the conflict in different ways: @@ -531,7 +536,7 @@ test_expect_success 'merge with outside renames' ' do test_all_match git reset --hard && test_all_match git checkout -f -b merge-$type update-deep && - test_all_match git merge -m "$type" rename-$type && + test_all_match git merge -sort -m "$type" rename-$type && test_all_match git rev-parse HEAD^{tree} || return 1 done ' From patchwork Tue Aug 17 17:08: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: 12441783 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.8 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 57A53C4338F for ; Tue, 17 Aug 2021 17:08:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A69A60FD9 for ; Tue, 17 Aug 2021 17:08:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231996AbhHQRJ1 (ORCPT ); Tue, 17 Aug 2021 13:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbhHQRJV (ORCPT ); Tue, 17 Aug 2021 13:09:21 -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 25752C0613CF for ; Tue, 17 Aug 2021 10:08:48 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id q11so29687873wrr.9 for ; Tue, 17 Aug 2021 10:08: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=EPp3Mz0DC9MjlMnYCAKfV25Pr4V1EcMULCjq6Yxkm54=; b=HswZdt8+tUINTQHa/z1FLZmQlCyDA8nmY6a2iy2bqtZKQ+DoooyFhNFxARhxEyX94w S+c6csnonA0ATAxju3k9msY+NCH+zM38GJT0oZXMBKGZyPUKfawFTA7hCoFB80e139wa 2F/s394QR5BCByR+WOAM1Hkl0AjluLa+llFGq5iF9epnI0h40bPmqGuELuRUT90QT7Ql DxfkcGh9NQ5jYqoFZYq/hcsHWP7iIZo4EcUEAxGJdaK34R6jXomX1dZ6+bWfSDNnDT7l p0TkCvlFWb/r9BtP8/Fcp98xM9kCl2vUUV04cnm2gVJp1u76NqFguJXBhYSRbiE5jioP 2MgA== 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=EPp3Mz0DC9MjlMnYCAKfV25Pr4V1EcMULCjq6Yxkm54=; b=Wg/zyBgByIGIAr6uDo592GrMiDQx+4BVfFPOCMKkf4s3JK5airExWjGaRo/KnOQIjH t+/E/x2Ep8epqFuw6hj18FsJ8x8H63O1UPCe/DUJX7/57XApKRnA97buYWEHTmB0IuuJ KcIbSjQaqC5Y5OEiDDMX5YjioX5STmEmAJKM+AC5QpDk/Kciwbdlj800n6rMUZj1R2HI NlRyf/Z59pzpmXg4PzxYh13di951f10xRnqLUav9cWerKckHGSBH4YyVMpcjBlC/OAe7 Xrw0jkkcUNQnZUbh+4v2EmeHeM8JbiL00OytwS1F15FOEozsVSddrXrQeIOvz4OH1/3u DgZQ== X-Gm-Message-State: AOAM533CjHc3d7MkT0OFj7qaIjee64iIeQyyUM/r6vc4ChWfMGgCKKos gx1KUEqcikWU/W43elq142ktBneRLhc= X-Google-Smtp-Source: ABdhPJzLnw9vC3/cSGL2TPkFEVP3nAD1A3gqn6rq27BRet8jDph7Nld1Tyw7JtoUZPrABjDDARJIuw== X-Received: by 2002:adf:8102:: with SMTP id 2mr5364280wrm.89.1629220126821; Tue, 17 Aug 2021 10:08:46 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t1sm2805703wma.25.2021.08.17.10.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 10:08:46 -0700 (PDT) Message-Id: <9f50f11d394e46ffbe348a579792c2b683096452.1629220124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 17 Aug 2021 17:08:40 +0000 Subject: [PATCH 2/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, 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, especially when a conflict appears. 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. Signed-off-by: Derrick Stolee --- diff.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/diff.c b/diff.c index a8113f17070..c457cfa0e59 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 @@ -3900,6 +3901,13 @@ static int reuse_worktree_file(struct index_state *istate, if (!FAST_WORKING_DIRECTORY && !want_file && has_object_pack(oid)) 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; + /* * Similarly, if we'd have to convert the file contents anyway, that * makes the optimization not worthwhile. From patchwork Tue Aug 17 17:08: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: 12441785 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 450FEC432BE for ; Tue, 17 Aug 2021 17:08:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2543960FD9 for ; Tue, 17 Aug 2021 17:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbhHQRJ2 (ORCPT ); Tue, 17 Aug 2021 13:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231570AbhHQRJW (ORCPT ); Tue, 17 Aug 2021 13:09:22 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D90DBC061796 for ; Tue, 17 Aug 2021 10:08:48 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 79-20020a1c0452000000b002e6cf79e572so2437629wme.1 for ; Tue, 17 Aug 2021 10:08: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=ro893bLvb1ewTMCxZ8A9UF4Z5ELXQAo6aO7w7HpWQBc=; b=T547T3ZNLnftqFv1OqxI/k1YpOLuLYeXbpfbIzozRRlaKwkwPEXQ980Nz9A9qNCaXA r0RJVWBlqxQX52o08VqV4UiU1Oo5gTQgqy57QbSogDW+jVfWrzNhRW4JHl1HtKkB7a9k swl5g7Rjp19ra9FQWEbKZ2W4DS5yZILQBwGwbvfn40mhc3eBtFBrxr7lVNthN85SxDbu dBBVFkg6hHh66pGj57gE16qaqqAAgtKWWCuuoebJ804oKeWcJPFDML2r1c/FZSYwGSu1 qzd3zWRqc+lZ+v6+0R04jNUSP5ElSn7jF/JLpDunpTXQPDX5QexGXYHaEPxvJSirqDtN RjDw== 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=ro893bLvb1ewTMCxZ8A9UF4Z5ELXQAo6aO7w7HpWQBc=; b=HM9ZmCH/MP2EXV9pOtFep5cng9AkWBwVS3Kmxo+X0KpJaqOPL65ROt1wCmuhVNY+t0 e5+I3K34MQcig4JK6s5Zx6CoNvxGAGwNvTqyPddqxBNu39lxHXHop/+5ABIBZf+46xK2 qvK1hpVh54m7rzfrpvq+Kt0XNxFQUkoIhnmQmTrFWhViIv1SA6+BhEMToixzkAySyxI7 gV3VftN7Cw2pAZL+YX0J4PG0bsQqT6pThriXQnK9wj7OQnCO5N3fsNpYHLHLAZfRWuRh EVToHS9+QC/bCR0BgtY1mXu1H15fK/J2PTOb3qjJp1DWZVWeqUga6WhUItU9pRVMaHaf MR9w== X-Gm-Message-State: AOAM533pcMIdaycNduCVKfBum7e3K5eNWSvx7aQr+XL4YGrphhbsMmTM vPO1A1Ili0swdreI3qD8C8bRlRtlcIA= X-Google-Smtp-Source: ABdhPJxQNfq4ZOMLx0Qjv/WEODOYiU+Y5sU5Ewxp9L1K1JzA9KHwXrnxy7aUA9wQxIsGeMxbtCNbpg== X-Received: by 2002:a7b:c1d7:: with SMTP id a23mr4488406wmj.69.1629220127453; Tue, 17 Aug 2021 10:08:47 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i21sm3158632wrb.62.2021.08.17.10.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 10:08:47 -0700 (PDT) Message-Id: <4c1104a0dd3af4a895df42f43306c24965a0323c.1629220124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 17 Aug 2021 17:08:41 +0000 Subject: [PATCH 3/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, 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. 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. 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 | 8 ++++++-- 4 files changed, 20 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 3e01e70fa0b..781ebd9a656 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -52,7 +52,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 && @@ -652,7 +652,11 @@ 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 && + ensure_not_expanded merge -s ort -m merge update-folder1 && + ensure_not_expanded merge -s ort -m merge update-folder2 ' # NEEDSWORK: a sparse-checkout behaves differently from a full checkout From patchwork Tue Aug 17 17:08: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: 12441787 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 3A1C8C4338F for ; Tue, 17 Aug 2021 17:08:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EF6060FD9 for ; Tue, 17 Aug 2021 17:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbhHQRJa (ORCPT ); Tue, 17 Aug 2021 13:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231637AbhHQRJX (ORCPT ); Tue, 17 Aug 2021 13:09:23 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 885D8C06179A for ; Tue, 17 Aug 2021 10:08:49 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id o15so625440wmr.3 for ; Tue, 17 Aug 2021 10:08: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=Ev/we/PiyCSnXRohXJH3BmgEao9qB47yJWiBW2A7p8c=; b=ZoEMaGOZUSzHqvjIArYvFwsZwtr0SutYPDBiIUCGVZyLpi4oMXUgyGfgG7U5JktnFk Kg8VB5ury8IqX1rZuLfeIX87Xig72+hKQcWPlVYD4jsfoUV5vdOhbma0LzZ33K+0jHW3 BC9vLalxQXY7nTQdbRZJAjL4DwuuIE0GXY0i0emYLaSTsDHsMeXoLTl662StiwDN5CtZ MioeGaCOQS9umbTeQFdCUk7qTb49GMP4C9LdAbPeMAxK0qrpjxEKc4JkPG/K4EewdziD pjNsjyL4GJEilWbEhWGrlGpOSGTGuKfk5GR8fIRPGtF+EeObEpwV/SpYC0dQC24/8sGK xzig== 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=Ev/we/PiyCSnXRohXJH3BmgEao9qB47yJWiBW2A7p8c=; b=En1MtbBMUJxRSq5gf11t6n8hXp1ZJMg/V4++7OSXZmoRvlEnehpusLebibhxw5IBeX CDAx9Vz2NLpg+6u3roWkpDS1bW7lEfT9YPndBNxzmnQtd3PM3gD+ENzlAPnmOEZnJ45y bhzl4FCC0453k3XNzYm8x1qZbSi0OIHIK/+0IMkMRSlbnmyi++Mrkd0szcApfFkISUeX hgkD+xInYnXhCvah+gDdV6fgRDR/mm7fZ6YD09F1bq0yABB325R/qm+GVhGgYQ9ps440 idbuC6D/UOxbm99jxulJ2XWwm3vRGp8+2JSJgShxLPICPH5kWuJqsAGSiiCDz5J635/p eF6Q== X-Gm-Message-State: AOAM5337WoqVb6opUFqcz2Mu5ZBC54QHC9Bj0i2UR1WLisyAhjXrOE5r L1U0EzHptMTsua/dwqOn0ufrpNC/4uI= X-Google-Smtp-Source: ABdhPJypJuft8Ypcijv3OGSz4TgAOeA93l6Twc/oAAtHgx+dyPnT5NqcZEZZ3w0MVhbG5omqe4iwiA== X-Received: by 2002:a1c:9ace:: with SMTP id c197mr4481609wme.170.1629220128030; Tue, 17 Aug 2021 10:08:48 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l19sm2849770wmi.4.2021.08.17.10.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 10:08:47 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 17 Aug 2021 17:08:42 +0000 Subject: [PATCH 4/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, 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 | 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" /* * 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; + } + } /* 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 + ) + 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' ' From patchwork Tue Aug 17 17:08: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: 12441789 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.8 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 0285BC432BE for ; Tue, 17 Aug 2021 17:09:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E44D26102A for ; Tue, 17 Aug 2021 17:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbhHQRJb (ORCPT ); Tue, 17 Aug 2021 13:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbhHQRJX (ORCPT ); Tue, 17 Aug 2021 13:09:23 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73EBC061764 for ; Tue, 17 Aug 2021 10:08:49 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id c129-20020a1c35870000b02902e6b6135279so2666323wma.0 for ; Tue, 17 Aug 2021 10:08: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=7uWZFU2odf9jKIn2gJNnia4alxezRzTcFj0oEShO97A=; b=ay+odKkwMH+njSbhd/BJk42R/XOagf3gfCrSs0Q30pCalS91ml60vE/Yv8hqzaay2G 4uBMG6adaqu2836C9O9LMpldEBI+Aqt81mpvBC4X5EqQ/7jvHBJQYrG6PAVgmeDUafh1 is6ZO1K/Z20IicQJ1E5CErHRpEXTo3oxLE4m5A+Ad0HGnJMWeTIgxZrnyXYcuc802ERQ 1l9nbTw3HBbX+kKkR1uZu6oivH5T//F4Qgs6Tr9q638IsfYRRjpQxKQdotcEWi0JuT9y bYkRvFwixtSVJKOMk3F2UJZ2dyASscXFIwszcYZzK1CHSrL+u27w2OJ4K2RrZbPDe3kX gMZg== 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=7uWZFU2odf9jKIn2gJNnia4alxezRzTcFj0oEShO97A=; b=kjLxisdai4ZuY1ned1H0cTAKmSAjEefjP9qfrEpRJF0UzdGfaMmvif33zJKvYDLKC6 +8J9EgyzyKSaJAMbHGLaWefgoVZ4+XW0deldVNqlPbU3eDiwjD19Lk/+z5Yp8mMZ0/D0 zY2/avL+cdCIjZfbzqETftRM4OdSbvoi+dfXZcoRUIsYH3d4W7lLJR2ITT7tnxq9sgZS tTDvp3fMzNpwyAk2Jafmv7hHSa45WTvtx3ZO+UP097B6siqDoRuebzqfrahsIHT2u+sK qneuW9aCPZAz+6DBmN5AFEAbBHXpIrncjyAC01w3UIEZ6CndTd+tbvYvILgV+pwnetVm JJuA== X-Gm-Message-State: AOAM531k+sKKrqQNxkvUpxmd3RUnHk0acvnjKwTh65etmdqG95HpR/jO r4uT47+XJoW01V9kaCwQ3yPpNV6oFjA= X-Google-Smtp-Source: ABdhPJwSJQOzsEA1ZWvDGzveHZfBdD8WY9ViHBYNY/jW5RvOWwyLSswzAvY1k+A+9FKxhePXLUXdFg== X-Received: by 2002:a1c:f206:: with SMTP id s6mr4392180wmc.15.1629220128641; Tue, 17 Aug 2021 10:08:48 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l38sm2508495wmp.15.2021.08.17.10.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 10:08:48 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 17 Aug 2021 17:08:43 +0000 Subject: [PATCH 5/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, 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. 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 a0ed2bec574..a52d2edda54 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -486,14 +486,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 -s ort -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 17 17:08: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: 12441791 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 A39DFC4338F for ; Tue, 17 Aug 2021 17:09:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BBB860FD9 for ; Tue, 17 Aug 2021 17:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232245AbhHQRJd (ORCPT ); Tue, 17 Aug 2021 13:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231874AbhHQRJY (ORCPT ); Tue, 17 Aug 2021 13:09:24 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC10CC0613CF for ; Tue, 17 Aug 2021 10:08:50 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id h24-20020a1ccc180000b029022e0571d1a0so2629401wmb.5 for ; Tue, 17 Aug 2021 10:08: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=SXglbYF5i3mCU+SWgUZKfoy6r5uUdP5lH28zMDqaTwk=; b=G9RGfQG/dnQyf4l+3hw8ydM3kkc0ZsKHJ322gMQGhMXSjdiZarf9P71iMzBoKUpOrE RQ1odjNe1o084LiWX6hoT1NaITGyDJEdGiKBzM8H854kpn7Nt/hE/ei6KQGJxj2Ccub5 VN1tLNnXcNqKpzdVApwJXOojX7+M7V4J72gaInnTk2IEd4hsqFtpI/dMfSn2PN7dOS0N GE45JOvXL51dJe8DjwEFj2Zcey0lkebzlysyZP8jxuDFdoIJipDoFMFT7ELNy9x2Hxja Ys+C8CLkqOqb4yEizSgoF0im5y6u3iKxkbkZQoE/7mxY9NeEpm4rGiUAQTq46HmNl4OT rkOQ== 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=SXglbYF5i3mCU+SWgUZKfoy6r5uUdP5lH28zMDqaTwk=; b=E0pFV+73ICcL+K6PQWvtsaxl1gGeLbZqNDjL7o9b7PVj05RmssE7+/BVNsQk300eNg xZ8+WfyqPZLTNaTeaq6QmAkigFfFlU0Vqv638DQYvYkzR1hrUpNZdDheqeFwPe0j0dev MX8ZEDwdHl+INT8gDWfb/fT17DnyJjsXZOz/onO1OVZFvmMWq/HOHKiLp+QkW4SurZtS 60zXy35o1q0qDRqsAblDqiXjj7m1f6A5CtJK86FO8R4lzi4pnO1xzOReDoj0fXuG0z3x ZC65oJ4u/Y/a8f+O2NDXKWkIHfcoO4CTXu9C6c9qR5kXHyxXCKgLDM+3MT2l3Qr3V5Go OmHw== X-Gm-Message-State: AOAM5307vJgLkvJcDeAOaN5HEvyZ8u6plxa98WvZM7cAci9b7WdApT5e 0FM46SxQAOP6ZAgNq5G834100h8/oo8= X-Google-Smtp-Source: ABdhPJynaYGj7GPDTCwdyolQDSxcT++5V8la7SHNtwPteV8x8G3bTjpbnS83s0diNsCBw5Qkg0xMPA== X-Received: by 2002:a05:600c:b51:: with SMTP id k17mr4419487wmr.149.1629220129361; Tue, 17 Aug 2021 10:08:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w11sm3177028wrr.48.2021.08.17.10.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 10:08:48 -0700 (PDT) Message-Id: <350ed86a4533d7fe332aebdf88cc474ceaf30ffe.1629220124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 17 Aug 2021 17:08:44 +0000 Subject: [PATCH 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, 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 | 41 ++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 3 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 a52d2edda54..c047b95b121 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -532,6 +532,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 && @@ -670,9 +702,12 @@ test_expect_success 'sparse-index is not expanded' ' echo >>sparse-index/untracked.txt && ensure_not_expanded add . && - ensure_not_expanded checkout -f update-deep && - ensure_not_expanded merge -s ort -m merge update-folder1 && - ensure_not_expanded merge -s ort -m merge update-folder2 + for OPERATION in "merge -s ort -m merge" cherry-pick rebase + do + ensure_not_expanded checkout -f -B temp update-deep && + ensure_not_expanded $OPERATION update-folder1 && + ensure_not_expanded $OPERATION update-folder2 || return 1 + done ' test_expect_success 'sparse-index is not expanded: merge conflict in cone' '