From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id EF96B1F531 for ; Sat, 8 Aug 2020 07:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbgHHHuj (ORCPT ); Sat, 8 Aug 2020 03:50:39 -0400 Received: from out0.migadu.com ([94.23.1.103]:3772 "EHLO out0.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbgHHHuh (ORCPT ); Sat, 8 Aug 2020 03:50:37 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ameretat.dev; s=default; t=1596873035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=glBgxlqRoc726qEjzIsDt4SP3ZDO1phxk8WI1Lg/714=; b=ivjUwdhvQ5+2XhuGm4UNp4fOst5laD2ZbhZSSNnONliVLDML4po1f6Sa2y9O8is26/ijru 22F9bukw6FggoswkNaGrptHe1W9I6RVJdHzx6hFEBujBi54dp69Dizi7WzRgY0iiqWamBQ IGP823LetaOgbZWC0F4rgBc7ScLw9eQ= From: "Raymond E. Pasco" To: Junio C Hamano Cc: git@vger.kernel.org, "Raymond E. Pasco" Subject: [PATCH v5 3/3] t4140: test apply with i-t-a paths Date: Sat, 8 Aug 2020 03:49:59 -0400 Message-Id: <20200808074959.35943-4-ray@ameretat.dev> In-Reply-To: <20200808074959.35943-1-ray@ameretat.dev> References: <20200806060119.74587-1-ray@ameretat.dev> <20200808074959.35943-1-ray@ameretat.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org apply --cached (as used by add -p) should accept creation and deletion patches to intent-to-add paths in the index. apply --index, however, should always fail because an intent-to-add path never matches the worktree (by definition). Based-on-patch-by: Junio C Hamano Signed-off-by: Raymond E. Pasco --- t/t4140-apply-ita.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 t/t4140-apply-ita.sh diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh new file mode 100755 index 0000000000..c614eaf04c --- /dev/null +++ b/t/t4140-apply-ita.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +test_description='git apply of i-t-a file' + +. ./test-lib.sh + +test_expect_success setup ' + test_write_lines 1 2 3 4 5 >blueprint && + + cat blueprint >test-file && + git add -N test-file && + git diff >creation-patch && + grep "new file mode 100644" creation-patch && + + rm -f test-file && + git diff >deletion-patch && + grep "deleted file mode 100644" deletion-patch +' + +test_expect_success 'apply creation patch to ita path (--cached)' ' + git rm -f test-file && + cat blueprint >test-file && + git add -N test-file && + + git apply --cached creation-patch && + git cat-file blob :test-file >actual && + test_cmp blueprint actual +' + +test_expect_success 'apply creation patch to ita path (--index)' ' + git rm -f test-file && + cat blueprint >test-file && + git add -N test-file && + rm -f test-file && + + test_must_fail git apply --index creation-patch +' + +test_expect_success 'apply deletion patch to ita path (--cached)' ' + git rm -f test-file && + cat blueprint >test-file && + git add -N test-file && + + git apply --cached deletion-patch && + test_must_fail git ls-files --stage --error-unmatch test-file +' + +test_expect_success 'apply deletion patch to ita path (--index)' ' + cat blueprint >test-file && + git add -N test-file && + + test_must_fail git apply --index deletion-patch && + git ls-files --stage --error-unmatch test-file +' + +test_done -- 2.28.0.5.gfc8e108108