From patchwork Thu Jun 30 02:37:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12900997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F8BDC433EF for ; Thu, 30 Jun 2022 02:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231769AbiF3CiA (ORCPT ); Wed, 29 Jun 2022 22:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231955AbiF3Chu (ORCPT ); Wed, 29 Jun 2022 22:37:50 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2361D23162 for ; Wed, 29 Jun 2022 19:37:50 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id x4so16838222pfq.2 for ; Wed, 29 Jun 2022 19:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NyBk/n5Xb1g9Y6Zvz48uQ/XmYg2QSFrTAGliHe5zU3k=; b=BEJ6w6XKIQuZBV7QzcOaGXzDEIcNP36CLM5K08UTK8u9/peSWxRjdL3gPU/Ud4gjfA uQfEXALFMgJLBfwRiPx23ikBFr5AG34kGe+vtNisxRuN7sJjAb56i9H32KGHp+y0s7dQ hjMHg9aF7ylzBemqMipwEuVnU8IKzLCTGxOXM4Yupj/eiVbebY9V0LjPtDIpj8sMKyGb rNS8Zxx70ODjoBDIiCvsFuwMjfUxM8xCLDlMtk9Uy2nsMc4PH5Cyl5q57Hkg1WMzV5pG Zg2WJZ6xEqCa5XVF3qK6eHpRTkcb4ewVvs2/vM+vnBoUGs2sucUH+AsiNJcUUangAwtS 4hsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NyBk/n5Xb1g9Y6Zvz48uQ/XmYg2QSFrTAGliHe5zU3k=; b=abUzrKNOWLaFMw+Ze61PwhsPRDJztuFRIYITiNjg/lV4WGw0TXZRmV4YeFQ4zk33fT VA+Og241kyWlxdL8sn6AcMSFScjrEIeW6HpYKCM2suXF0waljm9Rcb0vsNp+nTC3N01p 7oXjuG82AlL9HuxF1/DY88LYvLGriOI+IQlZMFzApm0A8f46Z74cnB8/JNTKygOgThf8 2EA6v+MMvV0YjwHqrCvOHKBO5XEaVHkETNo0lp+P9mAx7Yjn0ZYiQlvjfZpRTLl3wDrt c5fXZe0ie0hVwZ7tF9FrJwnUrMXXY45QJC9lRbvSFbW97mgXxS+Rb6/hNPLjVQ3zGzne eYZA== X-Gm-Message-State: AJIora/9wRp8VhwEOZom7Il/40CfHQFakBUfo7zVqQ9jJyIehfeC4v7L yP7ZU8kVQG4QPbLdCT4G7Lm3JAQBc/4= X-Google-Smtp-Source: AGRyM1s3YchN3qBxb0pQIH9GQu6Xt1NWyurmzGG6VUvrcUQHqD4gC+FxsiaNkHoammNoaeyJs8E9pw== X-Received: by 2002:a05:6a00:3006:b0:525:266a:852e with SMTP id ay6-20020a056a00300600b00525266a852emr13294421pfb.60.1656556669450; Wed, 29 Jun 2022 19:37:49 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:37:48 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 1/8] t7002: add tests for moving out-of-cone file/directory Date: Thu, 30 Jun 2022 10:37:30 +0800 Message-Id: <20220630023737.473690-2-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add corresponding tests to test following situations: We do not have sufficient coverage of moving files outside of a sparse-checkout cone. Create new tests covering this behavior, keeping in mind that the user can include --sparse (or not), move a file or directory, and the destination can already exist in the index (in this case user can use --force to overwrite existing entry). Helped-by: Victoria Dye Helped-by: Derrick Stolee Signed-off-by: Shaoxuan Yuan --- t/t7002-mv-sparse-checkout.sh | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/t/t7002-mv-sparse-checkout.sh b/t/t7002-mv-sparse-checkout.sh index f0f7cbfcdb..023e657c9e 100755 --- a/t/t7002-mv-sparse-checkout.sh +++ b/t/t7002-mv-sparse-checkout.sh @@ -4,6 +4,18 @@ test_description='git mv in sparse working trees' . ./test-lib.sh +setup_sparse_checkout () { + mkdir folder1 && + touch folder1/file1 && + git add folder1 && + git sparse-checkout set --cone sub +} + +cleanup_sparse_checkout () { + git sparse-checkout disable && + git reset --hard +} + test_expect_success 'setup' " mkdir -p sub/dir sub/dir2 && touch a b c sub/d sub/dir/e sub/dir2/e && @@ -196,6 +208,7 @@ test_expect_success 'can move files to non-sparse dir' ' ' test_expect_success 'refuse to move file to non-skip-worktree sparse path' ' + test_when_finished "cleanup_sparse_checkout" && git reset --hard && git sparse-checkout init --no-cone && git sparse-checkout set a !/x y/ !x/y/z && @@ -206,4 +219,75 @@ test_expect_success 'refuse to move file to non-skip-worktree sparse path' ' test_cmp expect stderr ' +test_expect_failure 'refuse to move out-of-cone directory without --sparse' ' + test_when_finished "cleanup_sparse_checkout" && + setup_sparse_checkout && + + test_must_fail git mv folder1 sub 2>stderr && + cat sparse_error_header >expect && + echo folder1/file1 >>expect && + cat sparse_hint >>expect && + test_cmp expect stderr +' + +test_expect_failure 'can move out-of-cone directory with --sparse' ' + test_when_finished "cleanup_sparse_checkout" && + setup_sparse_checkout && + + git mv --sparse folder1 sub 2>stderr && + test_must_be_empty stderr && + + test_path_is_dir sub/folder1 && + test_path_is_file sub/folder1/file1 +' + +test_expect_failure 'refuse to move out-of-cone file without --sparse' ' + test_when_finished "cleanup_sparse_checkout" && + setup_sparse_checkout && + + test_must_fail git mv folder1/file1 sub 2>stderr && + cat sparse_error_header >expect && + echo folder1/file1 >>expect && + cat sparse_hint >>expect && + test_cmp expect stderr +' + +test_expect_failure 'can move out-of-cone file with --sparse' ' + test_when_finished "cleanup_sparse_checkout" && + setup_sparse_checkout && + + git mv --sparse folder1/file1 sub 2>stderr && + test_must_be_empty stderr && + + test_path_is_file sub/file1 +' + +test_expect_failure 'refuse to move sparse file to existing destination' ' + test_when_finished "cleanup_sparse_checkout" && + mkdir folder1 && + touch folder1/file1 && + touch sub/file1 && + git add folder1 sub/file1 && + git sparse-checkout set --cone sub && + + test_must_fail git mv --sparse folder1/file1 sub 2>stderr && + echo "fatal: destination exists, source=folder1/file1, destination=sub/file1" >expect && + test_cmp expect stderr +' + +test_expect_failure 'move sparse file to existing destination with --force and --sparse' ' + test_when_finished "cleanup_sparse_checkout" && + mkdir folder1 && + touch folder1/file1 && + touch sub/file1 && + echo "overwrite" >folder1/file1 && + git add folder1 sub/file1 && + git sparse-checkout set --cone sub && + + git mv --sparse --force folder1/file1 sub 2>stderr && + test_must_be_empty stderr && + echo "overwrite" >expect && + test_cmp expect sub/file1 +' + test_done From patchwork Thu Jun 30 02:37:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12900999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AEE4C433EF for ; Thu, 30 Jun 2022 02:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231959AbiF3CiD (ORCPT ); Wed, 29 Jun 2022 22:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231972AbiF3Chx (ORCPT ); Wed, 29 Jun 2022 22:37:53 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77BD224BFD for ; Wed, 29 Jun 2022 19:37:52 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id s206so8127453pgs.3 for ; Wed, 29 Jun 2022 19:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VRW9QNmQJR07WHGrS+cRatkXvEi8pyOQnwtXDuaN2Vs=; b=BRuqwAkFeU522GDRD8NDiCjNw9nZugAtJYRcRecMgTG3zyqjm1QdzCF7xh87YkU1jn gyHp2jOZcl7b3mQQMclaVkkctBBo32MluwFqu4FnXyqRono6dMEnKSy7tEgqhycOx1gV zkeeY6SoSqokGM8AtxGePA9CMXanMVR0QKEltMiMxvyu7TxXpfZCg27EGTkfkZhabzxg ZaX8Rdl9PpzxAra68e7r/rXmivnQhYcsRM8U09eR6qSsB1JTkB9q5SWp7aBxfaMBmPmc N0XRCwdIWfk1UFX0WPO9usUOebq46m8Cs7fKP7kG5zc51481lj3K+vqxCpBs4mcX+iGs xa8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VRW9QNmQJR07WHGrS+cRatkXvEi8pyOQnwtXDuaN2Vs=; b=taUQTU2yqGtjRib+lAdl/t5a5yJwZ9MgDWIRix5u8qi5r81jNVYRVK1uyhzblIJ39h VFf9688hZP7c0P92mTZcEwrIoPf6VVzpxJCdssYe1L9aVNvh2hKTFZ5A4o30Eaw6jBOO +V/HM0wJRp82m32+MmDFKg1P9yT/coyd8ef8s48ObTBu4cn4/2J/Ap2orcLhsIBdnBzG 4JFAcAgsKuf0Enu4rD94UTNm/Xu2+r8ru3nswaU0s4iYPf3mBrt837i/dPP44KJBVjOq HPjceIQNV4sTisLvlN4ez24FkyW7JbLN1hjWUv7medKViULm2+g53dTSWpLTotxePPSh myKg== X-Gm-Message-State: AJIora8OsajOJGKVmiCliu3cJfSfg37Mwr8l1hZimg0Cc/BJAV55fwQV DIucrhYPNSSGEkJZA+TbYt2RLu0Iqf8= X-Google-Smtp-Source: AGRyM1vLOS8P6wW+9sEgEEbGDmfVaZ3jqCgq4kYevoPC8WyG2yx6U2oTyhNt39vGjhayyhOnr0ANyQ== X-Received: by 2002:aa7:947a:0:b0:528:ba5:290c with SMTP id t26-20020aa7947a000000b005280ba5290cmr2526951pfq.55.1656556671858; Wed, 29 Jun 2022 19:37:51 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:37:51 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 2/8] t1092: mv directory from out-of-cone to in-cone Date: Thu, 30 Jun 2022 10:37:31 +0800 Message-Id: <20220630023737.473690-3-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add test for "mv: add check_dir_in_index() and solve general dir check issue" in this series. This change tests the following: 1. mv as a directory on the sparse index boundary (where it would be a sparse directory in a sparse index). 2. mv as a directory which is deeper than the boundary (so the sparse index would expand in the cache_name_pos() method). These tests can be written now for correctness, but later the first case can be updated to use the 'ensure_not_expanded' helper in t1092. Suggested-by: Derrick Stolee Signed-off-by: Shaoxuan Yuan --- t/t1092-sparse-checkout-compatibility.sh | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index f9f8c988bb..5eef799e25 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -1828,4 +1828,29 @@ test_expect_success 'checkout behaves oddly with df-conflict-2' ' test_cmp full-checkout-err sparse-index-err ' +test_expect_failure 'mv directory from out-of-cone to in-cone' ' + init_repos && + + # as a sparse directory (or SKIP_WORKTREE_DIR without enabling + # sparse index). + test_all_match git mv --sparse folder1 deep && + test_all_match git status --porcelain=v2 && + test_sparse_match git ls-files -t && + git -C sparse-checkout ls-files -t >actual && + grep -e "H deep/folder1/0/0/0" actual && + grep -e "H deep/folder1/0/1" actual && + grep -e "H deep/folder1/a" actual && + + test_all_match git reset --hard && + + # as a directory deeper than sparse index boundary (where + # sparse index will expand). + test_sparse_match git mv --sparse folder1/0 deep && + test_sparse_match git status --porcelain=v2 && + test_sparse_match git ls-files -t && + git -C sparse-checkout ls-files -t >actual && + grep -e "H deep/0/0/0" actual && + grep -e "H deep/0/1" actual +' + test_done From patchwork Thu Jun 30 02:37:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12901000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7B61C433EF for ; Thu, 30 Jun 2022 02:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231964AbiF3CiF (ORCPT ); Wed, 29 Jun 2022 22:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbiF3Ch6 (ORCPT ); Wed, 29 Jun 2022 22:37:58 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E95321825 for ; Wed, 29 Jun 2022 19:37:57 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id s206so8127453pgs.3 for ; Wed, 29 Jun 2022 19:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BKY8VKeomF5uLQE+A3hpO0zka/Olvjbl7ArzwaV0FSw=; b=Pa9TkrEYspi5RXuYWMWOOx4P2aYaqpCZXV4VjqORLMoO1szG2q317sCfkHV1T4t2NM ZBL0zXuwi4eIa9CnPge1NTbDoVtAc5YVtA0RtGjnTsMZzRZlcHjETUy23kRbNDQky9md j8SrDeifqALHyIrZGDGYM7dN9UTDKf+dDuRIVsZzblX5llo6dN/VyuG6YmTUu5YCuIlx TOybgomHMYRDjnTb+vJ6859CQmKcxFKAUfkRxW4Rr2usV3Vt2cGx65JUngzHEGKVX3Qa z7y3FtHzA1kJrsHgDQTu9NfOc4dLIL+/DF7lj3j/fv/DG7n+ClyOwDIpOYo1XMM6R043 YfnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BKY8VKeomF5uLQE+A3hpO0zka/Olvjbl7ArzwaV0FSw=; b=maRr7GeH3+7idAp9DOw4FxdlrFiqaOu0BCaxoTOZ1oZIqhJQBUNTnYldiN5o9+jGsx kD/AqRiyFComS0AmmxoGukiHy/W36/9dD82kvGboUTi+7aVePXOl1HBpNnKpjUDffYKP 558KDKWAegLmIqWMQFtZo3RkkgNCPEqqxa1Xt6+alnu9eYNN9/habmiuDX9QYXLecHig 4DOOtpyb37AFQ2VAkBK7SkuTJYJYs0CkCNT+9F1PAbSk2sSZ356lWifRH1KffuGjOGbQ 2gQgAFWdAJwZgfRDTZmXSpfC77mAj0f6Us+7CsJeJT0BrWSwyHuTIRGrdgTlbuzjxLIN n2Jw== X-Gm-Message-State: AJIora+1rrAwsn+MC6MqHej2oaiWusrPSzaqrNp/BuRPZDK2cBg9fS9s 1WVLP+4T7tCrefmGlfUGy745IgLEzTY= X-Google-Smtp-Source: AGRyM1swPw12qxAHo0IesUJ3fvG89vWDQnvql6plwuG19MvC1reJnUACGVk7LI8IA4Tbi2B+vR1hmw== X-Received: by 2002:a63:de43:0:b0:40d:a0f0:441 with SMTP id y3-20020a63de43000000b0040da0f00441mr5493668pgi.121.1656556677042; Wed, 29 Jun 2022 19:37:57 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:37:56 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 3/8] mv: update sparsity after moving from out-of-cone to in-cone Date: Thu, 30 Jun 2022 10:37:32 +0800 Message-Id: <20220630023737.473690-4-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Originally, "git mv" a sparse file from out-of-cone to in-cone does not update the moved file's sparsity (remove its SKIP_WORKTREE bit). And the corresponding cache entry is, unexpectedly, not checked out in the working tree. Update the behavior so that: 1. Moving from out-of-cone to in-cone removes the SKIP_WORKTREE bit from corresponding cache entry. 2. The moved cache entry is checked out in the working tree to reflect the updated sparsity. Helped-by: Victoria Dye Signed-off-by: Shaoxuan Yuan --- builtin/mv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/builtin/mv.c b/builtin/mv.c index 83a465ba83..5f4eeadd5d 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -13,6 +13,7 @@ #include "string-list.h" #include "parse-options.h" #include "submodule.h" +#include "entry.h" static const char * const builtin_mv_usage[] = { N_("git mv [] ... "), @@ -304,6 +305,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix) const char *src = source[i], *dst = destination[i]; enum update_mode mode = modes[i]; int pos; + struct checkout state = CHECKOUT_INIT; + state.istate = &the_index; + + if (force) + state.force = 1; if (show_only || verbose) printf(_("Renaming %s to %s\n"), src, dst); if (show_only) @@ -328,6 +334,17 @@ int cmd_mv(int argc, const char **argv, const char *prefix) pos = cache_name_pos(src, strlen(src)); assert(pos >= 0); rename_cache_entry_at(pos, dst); + + if ((mode & SPARSE) && + (path_in_sparse_checkout(dst, &the_index))) { + int dst_pos; + + dst_pos = cache_name_pos(dst, strlen(dst)); + active_cache[dst_pos]->ce_flags &= ~CE_SKIP_WORKTREE; + + if (checkout_entry(active_cache[dst_pos], &state, NULL, NULL)) + die(_("cannot checkout %s"), active_cache[dst_pos]->name); + } } if (gitmodules_modified) From patchwork Thu Jun 30 02:37:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12901001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 628E9C433EF for ; Thu, 30 Jun 2022 02:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230234AbiF3CiJ (ORCPT ); Wed, 29 Jun 2022 22:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbiF3CiB (ORCPT ); Wed, 29 Jun 2022 22:38:01 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BBBB220F2 for ; Wed, 29 Jun 2022 19:38:00 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id x1-20020a17090abc8100b001ec7f8a51f5so1441229pjr.0 for ; Wed, 29 Jun 2022 19:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AhFqx2XWT2gzTkJUZnII+Ia+WoUDmYZrj/ggRcgtrVs=; b=KLkqxIr8Er+avEg8Jc2yonf/1fmeMRWMQ8M1Q4Fe6rTS0x/egh4IABwoeUj9qOvOh0 hdX4j9rnRAU0P58InTgqNgJqKOh+KQ0tRx/btA6ZZ8AvkYFMuezV26Fm3ur9asVfBz4n GZHL4RVBGUd9nIgGiJ6hMZd9l/zonfuOrZgOcfOYT9fq1qlJk9qxFMpHwIGQ8Bam4W89 cABc41MTFbd7Ud66X3xBn6J/Q4KXuOYyfAr52e9TJZFURpb/ggak1YJQ6Sn47oM+3wd2 Bbvc7Ow2tmPvZ5l7MrJfq+9vjcAh/5wTDAnWfQGbIlk3twwdf7DKMTQqQjI3adqQWkSZ wKAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AhFqx2XWT2gzTkJUZnII+Ia+WoUDmYZrj/ggRcgtrVs=; b=xlKcsBRUgpTw5y9npcbuSg0FsPZpRS8lc55508KaB0yTMlVlNkk24ijvDYl12jj+ZJ L3Qz7NJSuYVCC//MGYZbnOhi5NOvQIP4PgZbu651lIHTbDYpCV3nHGLdD8GPaETl8GLD Xlkl8IGLHr+YJ7CTbiqrSK1K5VSnEnVgM8QjMf9XKJK6ZSK+iQvG58MzRz61b8SdGrSL Q9mGcgKAY4bEMiiO2PBwWHEQ04xlLwf96wJGPVmr0VpsL8x9ru+wpgIuwvgow4lZaXhj iNjtQ4t/qgGcuMLb2gwzinHfKQRnsAg7RGZhT3LdAgEVFTuGdUQ0GZUCpGWUFyuYpGz9 aJGw== X-Gm-Message-State: AJIora9svv3gHstSO/MdJ+o7Qo58zv8AP6lqRnYty0foREcn+l4ukv7+ R7CBXI9C80Eu3KvXuzgYKBcC12ROJiM= X-Google-Smtp-Source: AGRyM1uRAVyleKAKqOzQ/4Ysu/MIsZ3EgVmm0M9gL7dpbF5bm3TS6RYPWepyfUR1swx7HUc2IdTW7g== X-Received: by 2002:a17:902:db0c:b0:16a:52c3:9f72 with SMTP id m12-20020a170902db0c00b0016a52c39f72mr12329822plx.96.1656556679835; Wed, 29 Jun 2022 19:37:59 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:37:58 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 4/8] mv: decouple if/else-if checks using goto Date: Thu, 30 Jun 2022 10:37:33 +0800 Message-Id: <20220630023737.473690-5-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Previous if/else-if chain are highly nested and hard to develop/extend. Refactor to decouple this if/else-if chain by using goto to jump ahead. Suggested-by: Derrick Stolee Signed-off-by: Shaoxuan Yuan --- builtin/mv.c | 139 +++++++++++++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 59 deletions(-) diff --git a/builtin/mv.c b/builtin/mv.c index 5f4eeadd5d..e800da3ab8 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -187,53 +187,68 @@ int cmd_mv(int argc, const char **argv, const char *prefix) length = strlen(src); if (lstat(src, &st) < 0) { /* only error if existence is expected. */ - if (modes[i] != SPARSE) + if (modes[i] != SPARSE) { bad = _("bad source"); - } else if (!strncmp(src, dst, length) && - (dst[length] == 0 || dst[length] == '/')) { + goto act_on_entry; + } + } + if (!strncmp(src, dst, length) && + (dst[length] == 0 || dst[length] == '/')) { bad = _("can not move directory into itself"); - } else if ((src_is_dir = S_ISDIR(st.st_mode)) - && lstat(dst, &st) == 0) + goto act_on_entry; + } + if ((src_is_dir = S_ISDIR(st.st_mode)) + && lstat(dst, &st) == 0) { bad = _("cannot move directory over file"); - else if (src_is_dir) { + goto act_on_entry; + } + if (src_is_dir) { + int j, dst_len, n; int first = cache_name_pos(src, length), last; - if (first >= 0) + if (first >= 0) { prepare_move_submodule(src, first, submodule_gitfile + i); - else if (index_range_of_same_dir(src, length, - &first, &last) < 1) + goto act_on_entry; + } else if (index_range_of_same_dir(src, length, + &first, &last) < 1) { bad = _("source directory is empty"); - else { /* last - first >= 1 */ - int j, dst_len, n; - - modes[i] = WORKING_DIRECTORY; - n = argc + last - first; - REALLOC_ARRAY(source, n); - REALLOC_ARRAY(destination, n); - REALLOC_ARRAY(modes, n); - REALLOC_ARRAY(submodule_gitfile, n); - - dst = add_slash(dst); - dst_len = strlen(dst); - - for (j = 0; j < last - first; j++) { - const struct cache_entry *ce = active_cache[first + j]; - const char *path = ce->name; - source[argc + j] = path; - destination[argc + j] = - prefix_path(dst, dst_len, path + length + 1); - modes[argc + j] = ce_skip_worktree(ce) ? SPARSE : INDEX; - submodule_gitfile[argc + j] = NULL; - } - argc += last - first; + goto act_on_entry; } - } else if (!(ce = cache_file_exists(src, length, 0))) { + + /* last - first >= 1 */ + modes[i] = WORKING_DIRECTORY; + n = argc + last - first; + REALLOC_ARRAY(source, n); + REALLOC_ARRAY(destination, n); + REALLOC_ARRAY(modes, n); + REALLOC_ARRAY(submodule_gitfile, n); + + dst = add_slash(dst); + dst_len = strlen(dst); + + for (j = 0; j < last - first; j++) { + const struct cache_entry *ce = active_cache[first + j]; + const char *path = ce->name; + source[argc + j] = path; + destination[argc + j] = + prefix_path(dst, dst_len, path + length + 1); + modes[argc + j] = ce_skip_worktree(ce) ? SPARSE : INDEX; + submodule_gitfile[argc + j] = NULL; + } + argc += last - first; + goto act_on_entry; + } + if (!(ce = cache_file_exists(src, length, 0))) { bad = _("not under version control"); - } else if (ce_stage(ce)) { + goto act_on_entry; + } + if (ce_stage(ce)) { bad = _("conflicted"); - } else if (lstat(dst, &st) == 0 && - (!ignore_case || strcasecmp(src, dst))) { + goto act_on_entry; + } + if (lstat(dst, &st) == 0 && + (!ignore_case || strcasecmp(src, dst))) { bad = _("destination exists"); if (force) { /* @@ -247,34 +262,40 @@ int cmd_mv(int argc, const char **argv, const char *prefix) } else bad = _("Cannot overwrite"); } - } else if (string_list_has_string(&src_for_dst, dst)) + goto act_on_entry; + } + if (string_list_has_string(&src_for_dst, dst)) { bad = _("multiple sources for the same target"); - else if (is_dir_sep(dst[strlen(dst) - 1])) + goto act_on_entry; + } + if (is_dir_sep(dst[strlen(dst) - 1])) { bad = _("destination directory does not exist"); - else { - /* - * We check if the paths are in the sparse-checkout - * definition as a very final check, since that - * allows us to point the user to the --sparse - * option as a way to have a successful run. - */ - if (!ignore_sparse && - !path_in_sparse_checkout(src, &the_index)) { - string_list_append(&only_match_skip_worktree, src); - skip_sparse = 1; - } - if (!ignore_sparse && - !path_in_sparse_checkout(dst, &the_index)) { - string_list_append(&only_match_skip_worktree, dst); - skip_sparse = 1; - } - - if (skip_sparse) - goto remove_entry; + goto act_on_entry; + } - string_list_insert(&src_for_dst, dst); + /* + * We check if the paths are in the sparse-checkout + * definition as a very final check, since that + * allows us to point the user to the --sparse + * option as a way to have a successful run. + */ + if (!ignore_sparse && + !path_in_sparse_checkout(src, &the_index)) { + string_list_append(&only_match_skip_worktree, src); + skip_sparse = 1; + } + if (!ignore_sparse && + !path_in_sparse_checkout(dst, &the_index)) { + string_list_append(&only_match_skip_worktree, dst); + skip_sparse = 1; } + if (skip_sparse) + goto remove_entry; + + string_list_insert(&src_for_dst, dst); + +act_on_entry: if (!bad) continue; if (!ignore_errors) From patchwork Thu Jun 30 02:37:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12901002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4A05C43334 for ; Thu, 30 Jun 2022 02:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231434AbiF3CiT (ORCPT ); Wed, 29 Jun 2022 22:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbiF3CiE (ORCPT ); Wed, 29 Jun 2022 22:38:04 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57B4E248EF for ; Wed, 29 Jun 2022 19:38:03 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id i8-20020a17090aee8800b001ecc929d14dso2366508pjz.0 for ; Wed, 29 Jun 2022 19:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uUBWU57BKFV2sTn/wPtrtu20bGU+hkpkuTCcqrLsJ5E=; b=I8oIstlkKEjrJpvOCrM2VgQm6HQ86wHD4/9aDuP2YvYag99B1rYI+m7beuIjklLOlu HNTBTNCuoUBTJq3onIqtvIV7onIIt1VRz4d3kQXto0997IUkAZle0cgxgYi55Z1AA3jM cita0H7o2a1pyNeFofeebfVmOYuz0EUkHdOqEU3hETsRO7M/c1uAePlmN4+YlpOY3ZO5 8lAK/quGMYrWbD6tFM9e+AOVnf3n09vaVzKHjK0YwY8zAu5zuOlJar1XYKjTPWJ3Bwc7 DZ0LfJiLSrIGCW5vzko/m2o/5aGkUFA8aUYgLxmUj0OoTH+oYer8FQsMpZnRgFUX78i+ Hf7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uUBWU57BKFV2sTn/wPtrtu20bGU+hkpkuTCcqrLsJ5E=; b=MWkLtlWITPLgmI3+LEr1iP/Ha5SuOvpCQf86Qe+wnCPXDkOkHZqeoGsZgPnQKEwKuB +KYPADVQswYLWmY8J7R0OhOnHHrKOOXQlysV9s2zoZop3IBKcsqEDQuziSbK/pFL3hUf eaWlk5pFhnQBnCtNL9KxAwDfUQn1BIo25yutE9nfzRVSS2bxkUTCwtMfRoJbvyix+5Qm JHG2X8LCHv34/W16sSkYku4qfVON7Bh4bRWTnLg8anf9b1VF7vMTJboZQTC/wjak6otl RWRs0AvH/WoLQM48C6KyNXmt5b7IR5p+8MfZYIvUuBDJb1RTZs1k4vVDAJMnUTqfnY/+ wpfg== X-Gm-Message-State: AJIora/XyXd3f7WfmJ0cgQVFNY4uy76HxgT72F3e29C30EzlWRb0l75P QJ8Um4xX84W5syRP3Tj0AVlRHQ4o10M= X-Google-Smtp-Source: AGRyM1vHESrKbFYEm3dIo7cGAsswYsxtrVqMYSKmB5hZZs5fXHIwT4Ydp6QGyoMUAaTThw/V1R6QSA== X-Received: by 2002:a17:902:ce83:b0:16a:4663:f34b with SMTP id f3-20020a170902ce8300b0016a4663f34bmr12288795plg.125.1656556682745; Wed, 29 Jun 2022 19:38:02 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:38:01 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 5/8] mv: check if out-of-cone file exists in index with SKIP_WORKTREE bit Date: Thu, 30 Jun 2022 10:37:34 +0800 Message-Id: <20220630023737.473690-6-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Originally, moving a file which is not on-disk but exists in index as a SKIP_WORKTREE enabled cache entry, "giv mv" command errors out with "bad source". Change the checking logic, so that such file makes "giv mv" command warns with "advise_on_updating_sparse_paths()" instead of "bad source"; also user now can supply a "--sparse" flag so this operation can be carried out successfully. Signed-off-by: Shaoxuan Yuan --- builtin/mv.c | 21 +++++++++++++++++++-- t/t7002-mv-sparse-checkout.sh | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/builtin/mv.c b/builtin/mv.c index e800da3ab8..520be85774 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -186,11 +186,28 @@ int cmd_mv(int argc, const char **argv, const char *prefix) length = strlen(src); if (lstat(src, &st) < 0) { - /* only error if existence is expected. */ - if (modes[i] != SPARSE) { + int pos; + const struct cache_entry *ce; + + pos = cache_name_pos(src, length); + if (pos < 0) { + /* only error if existence is expected. */ + if (modes[i] != SPARSE) + bad = _("bad source"); + goto act_on_entry; + } + + ce = active_cache[pos]; + if (!ce_skip_worktree(ce)) { bad = _("bad source"); goto act_on_entry; } + + if (!ignore_sparse) + string_list_append(&only_match_skip_worktree, src); + else + modes[i] = SPARSE; + goto act_on_entry; } if (!strncmp(src, dst, length) && (dst[length] == 0 || dst[length] == '/')) { diff --git a/t/t7002-mv-sparse-checkout.sh b/t/t7002-mv-sparse-checkout.sh index 023e657c9e..1510b5ed6a 100755 --- a/t/t7002-mv-sparse-checkout.sh +++ b/t/t7002-mv-sparse-checkout.sh @@ -241,7 +241,7 @@ test_expect_failure 'can move out-of-cone directory with --sparse' ' test_path_is_file sub/folder1/file1 ' -test_expect_failure 'refuse to move out-of-cone file without --sparse' ' +test_expect_success 'refuse to move out-of-cone file without --sparse' ' test_when_finished "cleanup_sparse_checkout" && setup_sparse_checkout && @@ -252,7 +252,7 @@ test_expect_failure 'refuse to move out-of-cone file without --sparse' ' test_cmp expect stderr ' -test_expect_failure 'can move out-of-cone file with --sparse' ' +test_expect_success 'can move out-of-cone file with --sparse' ' test_when_finished "cleanup_sparse_checkout" && setup_sparse_checkout && From patchwork Thu Jun 30 02:37:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12901003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5159DC433EF for ; Thu, 30 Jun 2022 02:38:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231731AbiF3Cig (ORCPT ); Wed, 29 Jun 2022 22:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231975AbiF3CiG (ORCPT ); Wed, 29 Jun 2022 22:38:06 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8041B326 for ; Wed, 29 Jun 2022 19:38:05 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id r1so15769707plo.10 for ; Wed, 29 Jun 2022 19:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8hEn+VekRkx6ZeGrcRSu5mFkG0APhvp1/f8Tq8zI1sI=; b=i3Fu4xIdlP2wL3z+TZ/QaGONSG41pwEAWwerk4TxAMRZGTcVJ8eG5YItdQx5w0RuXA Hn6J+F4b8/FDZlQ4yCJ825heq5wS/uCZty2nlMXOgpUsCfqvCJrDVEwU29g6thG+DjSH TRa95ke+vbg8Eg84/lybcCiqH6LGqtMPgcs9foc/+bHEbPHrImx4BoAjVHcKEE+TQ1g/ PShcUJNNgvGrdu0bhMwG9ZEoLnNNOH4siaXn/5Xv68ov7KlvUeGDjL8hdt31SBHw5dxY lpjRO63Mwkid0Iqowck7ewyrJk3IakW716slPxV11e7ubpjDY7bn1WJ8eq3EqwFin4AN Wp9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8hEn+VekRkx6ZeGrcRSu5mFkG0APhvp1/f8Tq8zI1sI=; b=MxqaCwff2diG9auE6kOebmYW0UnDIgLKQBBAP2o2oKFLakNbSfjInnQu+UJT6/M2Ia PlpR9yf82QCkZF4EyTkRZfMRxR8RKPohDm38rzNvb3Vb5rn5sLtHxp5d06R+YOdO2Q+p iYUZMV1QKeo9VgC3aNEHpGL10aOrkCOY1JBGEvXiooFQQ25uqw6K44+OrE+CTdvT2hPp LjDyHg9FQWOmzqtDksh7lY17A++PcKCLwOEfRpPQKsMYU+7jN8YMbrR7ExEeopEddY2o RC/WB534SDigpr0IJA2VjvqngODyGZxoo7cWdTquL+qYaPLGybuFO6sHPMV9e6GpcPMZ Vfeg== X-Gm-Message-State: AJIora8H2RDUi26iScg/96SN6fS4+MRNT9RKT0mTapJAF2qAogme+6B6 QDH3TohRZk+iEAAVX48m1NLg1r5kZMk= X-Google-Smtp-Source: AGRyM1t3vZj2K687sHL4p8U8PIcodORxaXt+SCGXOkXS7RAKj4ZD9VqFeNElUvLhl7DuvuQvPyg3sQ== X-Received: by 2002:a17:902:6b41:b0:16a:55f6:95ee with SMTP id g1-20020a1709026b4100b0016a55f695eemr13623717plt.156.1656556684845; Wed, 29 Jun 2022 19:38:04 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:38:04 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 6/8] mv: check if exists in index to handle overwriting Date: Thu, 30 Jun 2022 10:37:35 +0800 Message-Id: <20220630023737.473690-7-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Originally, moving a sparse file into cone can result in unwarned overwrite of existing entry. The expected behavior is that if the exists in the entry, user should be prompted to supply a [-f|--force] to carry out the operation, or the operation should fail. Add a check mechanism to do that. Signed-off-by: Shaoxuan Yuan --- builtin/mv.c | 15 ++++++++++++--- t/t7002-mv-sparse-checkout.sh | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/builtin/mv.c b/builtin/mv.c index 520be85774..7d9627938a 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -202,11 +202,20 @@ int cmd_mv(int argc, const char **argv, const char *prefix) bad = _("bad source"); goto act_on_entry; } - - if (!ignore_sparse) + if (!ignore_sparse) { string_list_append(&only_match_skip_worktree, src); - else + goto act_on_entry; + } + /* Check if dst exists in index */ + if (cache_name_pos(dst, strlen(dst)) < 0) { modes[i] = SPARSE; + goto act_on_entry; + } + if (!force) { + bad = _("destination exists"); + goto act_on_entry; + } + modes[i] = SPARSE; goto act_on_entry; } if (!strncmp(src, dst, length) && diff --git a/t/t7002-mv-sparse-checkout.sh b/t/t7002-mv-sparse-checkout.sh index 1510b5ed6a..6d2fb4f8d2 100755 --- a/t/t7002-mv-sparse-checkout.sh +++ b/t/t7002-mv-sparse-checkout.sh @@ -262,7 +262,7 @@ test_expect_success 'can move out-of-cone file with --sparse' ' test_path_is_file sub/file1 ' -test_expect_failure 'refuse to move sparse file to existing destination' ' +test_expect_success 'refuse to move sparse file to existing destination' ' test_when_finished "cleanup_sparse_checkout" && mkdir folder1 && touch folder1/file1 && @@ -275,7 +275,7 @@ test_expect_failure 'refuse to move sparse file to existing destination' ' test_cmp expect stderr ' -test_expect_failure 'move sparse file to existing destination with --force and --sparse' ' +test_expect_success 'move sparse file to existing destination with --force and --sparse' ' test_when_finished "cleanup_sparse_checkout" && mkdir folder1 && touch folder1/file1 && From patchwork Thu Jun 30 02:37:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12901004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BC11C43334 for ; Thu, 30 Jun 2022 02:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbiF3Cih (ORCPT ); Wed, 29 Jun 2022 22:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231699AbiF3CiT (ORCPT ); Wed, 29 Jun 2022 22:38:19 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A124219A for ; Wed, 29 Jun 2022 19:38:07 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id h9-20020a17090a648900b001ecb8596e43so1347204pjj.5 for ; Wed, 29 Jun 2022 19:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pKi2vCQNb2ZS0CuxuO6LgV7erG3i83Eul0GEsSVlS3c=; b=VkB/L+/EqimI2jCuyMmjzB91+0PSkzmg4K6iwFeDXIuOAo/Eo9+OBI7zFEUUB6NI3Q iRR1tkkSd2u05UDOJD+1EljQGObAiITyXHWQpInRyg07AeJrV2Wsyj5aEDGjoIYE4Yuc JKG0LqYfcWcUHo77Mr5CsP1k3Kn7OlXJ5hNCvCyVWElyzBUFULW8URexrkjQvv7RSDyG UNlk1fcwKvBE+9UGjutHike0CZ25BryP4DzyXacCzysJOqC87XLNEO7RiRlwzBd/HaBQ 9m7rLtAZOnd8DnmPQ6MG5g73RzJ4iRYCmIpQCoIN9qOiVpb45nwJz336nqiRqGZ7pD1I 9b6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pKi2vCQNb2ZS0CuxuO6LgV7erG3i83Eul0GEsSVlS3c=; b=d/yoBpK94/gjAsrCIe8sreRp5YpXgdpkQA/elKIXVl+51eL2WwekgKqc7oGg2LrRGp OypXDeidf5zefGRpSvOf3mXVP//17p139uxTV/hzzTQj2qX7G/X2MdeCd2l0ASrdl+oe ynmdCw3QvJSm06vLPrANSLKlmW6x1Ws5lcKx/x/UzE0amRTWFZvimiyDeXlAXNhUl5Ea cjF0uRKLho0SByCOWEwIbhaRrr/N1IE/n6uHzVJ7vb/7n0ED8+r1wCDV0+nyBzTOn4c/ OgBepdpRRNFWygI8TtgvH6cC5CKcShxrPcP7qhCq01ZMf5wGyEvxYhMjLb9CLn8CP6Ge KuAQ== X-Gm-Message-State: AJIora/xRal4joojsKh+szeUoIJ9hPbTtdml8OjoARI6fNPdTBbR4OeS Wp3/tNJaeVjy2byHBvg3Uo0/FOnUS0o= X-Google-Smtp-Source: AGRyM1sfqb8eCogHyHPw5EmHhrN1PNZ+svoJrvCyoLoMRT/JmzWEUzzAZh/fXEmTx/UJQT3DodfIGg== X-Received: by 2002:a17:902:8502:b0:16a:34a:e477 with SMTP id bj2-20020a170902850200b0016a034ae477mr12801377plb.40.1656556686853; Wed, 29 Jun 2022 19:38:06 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:38:06 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 7/8] mv: use flags mode for update_mode Date: Thu, 30 Jun 2022 10:37:36 +0800 Message-Id: <20220630023737.473690-8-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As suggested by Derrick [1], move the in-line definition of "enum update_mode" to the top of the file and make it use "flags" mode (each state is a different bit in the word). Change the flag assignments from '=' (single assignment) to '|=' (additive). Also change flag evaluation from '==' to '&', etc. [1] https://lore.kernel.org/git/22aadea2-9330-aa9e-7b6a-834585189144@github.com/ Helped-by: Victoria Dye Helped-by: Derrick Stolee Signed-off-by: Shaoxuan Yuan --- builtin/mv.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/builtin/mv.c b/builtin/mv.c index 7d9627938a..b805a0d0f6 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -20,6 +20,13 @@ static const char * const builtin_mv_usage[] = { NULL }; +enum update_mode { + BOTH = 0, + WORKING_DIRECTORY = (1 << 1), + INDEX = (1 << 2), + SPARSE = (1 << 3), +}; + #define DUP_BASENAME 1 #define KEEP_TRAILING_SLASH 2 @@ -130,7 +137,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) OPT_END(), }; const char **source, **destination, **dest_path, **submodule_gitfile; - enum update_mode { BOTH = 0, WORKING_DIRECTORY, INDEX, SPARSE } *modes; + enum update_mode *modes; struct stat st; struct string_list src_for_dst = STRING_LIST_INIT_NODUP; struct lock_file lock_file = LOCK_INIT; @@ -192,7 +199,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) pos = cache_name_pos(src, length); if (pos < 0) { /* only error if existence is expected. */ - if (modes[i] != SPARSE) + if (!(modes[i] & SPARSE)) bad = _("bad source"); goto act_on_entry; } @@ -208,14 +215,14 @@ int cmd_mv(int argc, const char **argv, const char *prefix) } /* Check if dst exists in index */ if (cache_name_pos(dst, strlen(dst)) < 0) { - modes[i] = SPARSE; + modes[i] |= SPARSE; goto act_on_entry; } if (!force) { bad = _("destination exists"); goto act_on_entry; } - modes[i] = SPARSE; + modes[i] |= SPARSE; goto act_on_entry; } if (!strncmp(src, dst, length) && @@ -243,7 +250,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) } /* last - first >= 1 */ - modes[i] = WORKING_DIRECTORY; + modes[i] |= WORKING_DIRECTORY; n = argc + last - first; REALLOC_ARRAY(source, n); REALLOC_ARRAY(destination, n); @@ -259,7 +266,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix) source[argc + j] = path; destination[argc + j] = prefix_path(dst, dst_len, path + length + 1); - modes[argc + j] = ce_skip_worktree(ce) ? SPARSE : INDEX; + memset(modes + argc + j, 0, sizeof(enum update_mode)); + modes[argc + j] |= ce_skip_worktree(ce) ? SPARSE : INDEX; submodule_gitfile[argc + j] = NULL; } argc += last - first; @@ -361,7 +369,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix) printf(_("Renaming %s to %s\n"), src, dst); if (show_only) continue; - if (mode != INDEX && mode != SPARSE && rename(src, dst) < 0) { + if (!(mode & (INDEX | SPARSE)) && + rename(src, dst) < 0) { if (ignore_errors) continue; die_errno(_("renaming '%s' failed"), src); @@ -375,7 +384,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) 1); } - if (mode == WORKING_DIRECTORY) + if (mode & (WORKING_DIRECTORY)) continue; pos = cache_name_pos(src, strlen(src)); From patchwork Thu Jun 30 02:37:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoxuan Yuan X-Patchwork-Id: 12901005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13EEAC433EF for ; Thu, 30 Jun 2022 02:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231887AbiF3Ciq (ORCPT ); Wed, 29 Jun 2022 22:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231751AbiF3Cig (ORCPT ); Wed, 29 Jun 2022 22:38:36 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81A78DF35 for ; Wed, 29 Jun 2022 19:38:10 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id jh14so15794012plb.1 for ; Wed, 29 Jun 2022 19:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9/JzyUB+8soeR+ytNEPgHPwCWP61ls7r/6McNW4S+iI=; b=Wv4hFRM20I6X7fwiStMUEkXO3tgo5bsWK8yxkLDp7MHm0AaD6162eXXFF8T4SC/fv5 ZmIkLci0HdBpayg1fM9gj8wjHstV9JVf0Bp6Efre3qtoJOIAY/vl281Y/SyG/Q+e8C2n BUcdVsTMiJWaV0JWFiqMcQYCeczNBI59X1Rzwrb6Wz56D+YTgbgcY0wE+F+N5NqjpmJy pyotxtV51bURRBUtP2btmnpfem591xVnFqHZITJBkGluA7JOzth1IPesqEIiXmfDa9XD oCG2hjoUWjp+bEQxnObBThiIVD0qLm5SsYUtF5MYlrslu6+9QkhjXtoijZhNAr4rhopU 4S7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9/JzyUB+8soeR+ytNEPgHPwCWP61ls7r/6McNW4S+iI=; b=K1L7qVK9dmquxc/Qcht232cBdkcersrmMfEZouSyb7PRX0TE80786c/tknFsdfh7tD CquroX20dP3z3MIxz51KY5f5eONMeDVYDzttAiUW8CFYTIS1RbTru1Co9Oa+oh96dQQN XZ6U7BK5xAXfA/u34DhGAEHc7USfAGE6hbR92vaNAkVEKBEZ5crjb713MEOccDs9rjUr p6LevHkjOnknzFTazzlg1p4T9tk3Ncg2fojfaLjTibHhRQBWqcQ4A3SWM4mJD2zDerQD HSMct3Vv8TnxziyQTsKGnURXHjQeJ2fcAC2bOvbp4yuqPnhN5bfeXsyIru3SGY3x9Ddn p+0A== X-Gm-Message-State: AJIora9MbQ+gXu7lIzYAhsuvWhtc0Ye6VRmv2T3Gd6nCcIac0n5lsbYN eJoKPZpaaTNfeSCbIRRaJDX8SK/s5mU= X-Google-Smtp-Source: AGRyM1vVL/khFV640/vwy9aVZPL59Qvqduj7ktmXHcvKUOM3PhKAda6jGNitIUeUt1DMRzEmJUjJOw== X-Received: by 2002:a17:90a:5309:b0:1ec:82a1:3b86 with SMTP id x9-20020a17090a530900b001ec82a13b86mr7242196pjh.54.1656556689252; Wed, 29 Jun 2022 19:38:09 -0700 (PDT) Received: from ffyuanda.localdomain ([101.206.226.29]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm12157509pls.100.2022.06.29.19.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 19:38:08 -0700 (PDT) From: Shaoxuan Yuan To: git@vger.kernel.org Cc: derrickstolee@github.com, vdye@github.com, gitster@pobox.com, Shaoxuan Yuan Subject: [PATCH v5 8/8] mv: add check_dir_in_index() and solve general dir check issue Date: Thu, 30 Jun 2022 10:37:37 +0800 Message-Id: <20220630023737.473690-9-shaoxuan.yuan02@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> References: <20220331091755.385961-1-shaoxuan.yuan02@gmail.com> <20220630023737.473690-1-shaoxuan.yuan02@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Originally, moving a directory which is not on-disk due to its existence outside of sparse-checkout cone, "giv mv" command errors out with "bad source". Add a helper check_dir_in_index() function to see if a directory name exists in the index. Also add a SKIP_WORKTREE_DIR bit to mark such directories. Change the checking logic, so that such directory makes "giv mv" command warns with "advise_on_updating_sparse_paths()" instead of "bad source"; also user now can supply a "--sparse" flag so this operation can be carried out successfully. Helped-by: Victoria Dye Helped-by: Derrick Stolee Signed-off-by: Shaoxuan Yuan --- builtin/mv.c | 50 +++++++++++++++++++++--- t/t1092-sparse-checkout-compatibility.sh | 2 +- t/t7002-mv-sparse-checkout.sh | 4 +- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/builtin/mv.c b/builtin/mv.c index b805a0d0f6..2a38e2af46 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -25,6 +25,7 @@ enum update_mode { WORKING_DIRECTORY = (1 << 1), INDEX = (1 << 2), SPARSE = (1 << 3), + SKIP_WORKTREE_DIR = (1 << 4), }; #define DUP_BASENAME 1 @@ -123,6 +124,36 @@ static int index_range_of_same_dir(const char *src, int length, return last - first; } +/* + * Check if an out-of-cone directory should be in the index. Imagine this case + * that all the files under a directory are marked with 'CE_SKIP_WORKTREE' bit + * and thus the directory is sparsified. + * + * Return 0 if such directory exist (i.e. with any of its contained files not + * marked with CE_SKIP_WORKTREE, the directory would be present in working tree). + * Return 1 otherwise. + */ +static int check_dir_in_index(const char *name) +{ + const char *with_slash = add_slash(name); + int length = strlen(with_slash); + + int pos = cache_name_pos(with_slash, length); + const struct cache_entry *ce; + + if (pos < 0) { + pos = -pos - 1; + if (pos >= the_index.cache_nr) + return 1; + ce = active_cache[pos]; + if (strncmp(with_slash, ce->name, length)) + return 1; + if (ce_skip_worktree(ce)) + return 0; + } + return 1; +} + int cmd_mv(int argc, const char **argv, const char *prefix) { int i, flags, gitmodules_modified = 0; @@ -184,7 +215,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) /* Checking */ for (i = 0; i < argc; i++) { const char *src = source[i], *dst = destination[i]; - int length, src_is_dir; + int length; const char *bad = NULL; int skip_sparse = 0; @@ -198,12 +229,17 @@ int cmd_mv(int argc, const char **argv, const char *prefix) pos = cache_name_pos(src, length); if (pos < 0) { + const char *src_w_slash = add_slash(src); + if (!path_in_sparse_checkout(src_w_slash, &the_index) && + !check_dir_in_index(src)) { + modes[i] |= SKIP_WORKTREE_DIR; + goto dir_check; + } /* only error if existence is expected. */ if (!(modes[i] & SPARSE)) bad = _("bad source"); goto act_on_entry; } - ce = active_cache[pos]; if (!ce_skip_worktree(ce)) { bad = _("bad source"); @@ -230,12 +266,14 @@ int cmd_mv(int argc, const char **argv, const char *prefix) bad = _("can not move directory into itself"); goto act_on_entry; } - if ((src_is_dir = S_ISDIR(st.st_mode)) + if (S_ISDIR(st.st_mode) && lstat(dst, &st) == 0) { bad = _("cannot move directory over file"); goto act_on_entry; } - if (src_is_dir) { + +dir_check: + if (S_ISDIR(st.st_mode)) { int j, dst_len, n; int first = cache_name_pos(src, length), last; @@ -369,7 +407,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) printf(_("Renaming %s to %s\n"), src, dst); if (show_only) continue; - if (!(mode & (INDEX | SPARSE)) && + if (!(mode & (INDEX | SPARSE | SKIP_WORKTREE_DIR)) && rename(src, dst) < 0) { if (ignore_errors) continue; @@ -384,7 +422,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) 1); } - if (mode & (WORKING_DIRECTORY)) + if (mode & (WORKING_DIRECTORY | SKIP_WORKTREE_DIR)) continue; pos = cache_name_pos(src, strlen(src)); diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 5eef799e25..763c6cc684 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -1828,7 +1828,7 @@ test_expect_success 'checkout behaves oddly with df-conflict-2' ' test_cmp full-checkout-err sparse-index-err ' -test_expect_failure 'mv directory from out-of-cone to in-cone' ' +test_expect_success 'mv directory from out-of-cone to in-cone' ' init_repos && # as a sparse directory (or SKIP_WORKTREE_DIR without enabling diff --git a/t/t7002-mv-sparse-checkout.sh b/t/t7002-mv-sparse-checkout.sh index 6d2fb4f8d2..71fe29690f 100755 --- a/t/t7002-mv-sparse-checkout.sh +++ b/t/t7002-mv-sparse-checkout.sh @@ -219,7 +219,7 @@ test_expect_success 'refuse to move file to non-skip-worktree sparse path' ' test_cmp expect stderr ' -test_expect_failure 'refuse to move out-of-cone directory without --sparse' ' +test_expect_success 'refuse to move out-of-cone directory without --sparse' ' test_when_finished "cleanup_sparse_checkout" && setup_sparse_checkout && @@ -230,7 +230,7 @@ test_expect_failure 'refuse to move out-of-cone directory without --sparse' ' test_cmp expect stderr ' -test_expect_failure 'can move out-of-cone directory with --sparse' ' +test_expect_success 'can move out-of-cone directory with --sparse' ' test_when_finished "cleanup_sparse_checkout" && setup_sparse_checkout &&