From patchwork Tue Aug 30 13:54:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959391 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 C77CCECAAD1 for ; Tue, 30 Aug 2022 13:54:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230450AbiH3Nyy (ORCPT ); Tue, 30 Aug 2022 09:54:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbiH3Nyf (ORCPT ); Tue, 30 Aug 2022 09:54:35 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50990EE04 for ; Tue, 30 Aug 2022 06:54:29 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id b16so6702207wru.7 for ; Tue, 30 Aug 2022 06:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=08yJomRBoQ6Yjeqi9A3chzlIQeCCUPVSzEQwULp2Unw=; b=MgfEjg3FO0CYpwLLDEFhPRr5SOj8a7Q0ikofGG3LKYLr2pDJGGzjt9EBfmjMGX29d+ NgOiQbRT4ehMbLOyzN9cp4ZRgiSrQA6AwVzdjSjCD1pTfFjgvK2t5xleccaOgU31vWd7 ixfqmqWv951dzMvQGkzojVsm1ZrEc9iU473LVJhgM9rQvEqiED4ckylSzGS/ozN0wMKR +3Bsq7vN09/tPWg05WZf7PbvMFVLdfBIQk+ITI8te3IQsy7KJDvBRH5lwxiiSZOfSv4W lSm85elBFj8zg8gWb2I8FZcAaeG9NcIx4w0G6agd3hhrC63hV/FbuAlBtfUtEryqyEFK Gqqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=08yJomRBoQ6Yjeqi9A3chzlIQeCCUPVSzEQwULp2Unw=; b=0Pfw+c3KbnXYAbfCar/7oUvB/A6Y64nSC7Cb0JId5M1++eTcyXRA9zyFFaSTWcaO/O NgRD7c5M3A+vun8RAtCIb2MaF2H6RrWN/LJ2vKPTtcjcGH3acTGjOT/WuOGe+vjx/Go+ iEbxv7S9uuujwjghbFYHg7ji2yEElrmkKLUQeSW/0rsv+z3sH3eWIVetwrVZrkQcieZi 99wO9wCT3MFkth1UXlLWTvSj2z3nPgeWRF5war6GwEA1ALm/3yO6OGaHMHquott7oy73 I/1UMme1Gc/aMSDaecT4Jz/2Cqx1taUqUDyS42WKIxPwSxSOIlQVXx6/bxXJSq6yF1J0 C1Nw== X-Gm-Message-State: ACgBeo1nIBpf8MW8u/S7YrGplHIIQTLUtAfVCXXVBcpT45y8mnIotNOf 78ynGX8PTchUkwsBg8dxVN56pnmP9PQ= X-Google-Smtp-Source: AA6agR57OaJUOo6jBuZQ1QNr4UNBckglNaLZLw1mIuJ6f3iDO/Emo1YGKha3xJr/SidsGnOfCwl0bw== X-Received: by 2002:a05:6000:178f:b0:221:7dcb:7cbf with SMTP id e15-20020a056000178f00b002217dcb7cbfmr9204498wrg.58.1661867667766; Tue, 30 Aug 2022 06:54:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a22-20020a05600c225600b003a3442f1229sm12769650wmm.29.2022.08.30.06.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 06:54:27 -0700 (PDT) Message-Id: <0691d7eaaa03e8bf8b460b9e20ec05eec09fb574.1661867664.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 13:54:22 +0000 Subject: [PATCH 1/3] add -p: avoid ambiguous signed/unsigned comparison Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin In the interactive `add` operation, users can choose to jump to specific hunks, and Git will present the hunk list in that case. To avoid showing too many lines at once, only a maximum of 21 hunks are shown, skipping the "mode change" pseudo hunk. The comparison performed to skip the "mode change" pseudo hunk (if any) compares a signed integer `i` to the unsigned value `mode_change` (which can be 0 or 1 because it is a 1-bit type). According to section 6.3.1.8 of the C99 standard (see e.g. https://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf), what should happen is an automatic conversion of the "lesser" type to the "greater" type, but since the types differ in signedness, it is ill-defined what is the correct "usual arithmetic conversion". Which means that Visual C's behavior can (and does) differ from GCC's: When compiling Git using the latter, `add -p`'s `goto` command shows no hunks by default because it casts a negative start offset to a pretty large unsigned value, breaking the "goto hunk" test case in `t3701-add-interactive.sh`. Let's avoid that by converting the unsigned bit explicitly to a signed integer. Note: This is a long-standing bug in the Visual C build of Git, but it has never been caught because t3701 is skipped when `NO_PERL` is set, which is the case in the `vs-test` jobs of Git's CI runs. Signed-off-by: Johannes Schindelin --- add-patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add-patch.c b/add-patch.c index 509ca04456b..3524555e2b0 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1547,7 +1547,7 @@ soft_increment: strbuf_remove(&s->answer, 0, 1); strbuf_trim(&s->answer); i = hunk_index - DISPLAY_HUNKS_LINES / 2; - if (i < file_diff->mode_change) + if (i < (int)file_diff->mode_change) i = file_diff->mode_change; while (s->answer.len == 0) { i = display_hunks(s, file_diff, i); From patchwork Tue Aug 30 13:54:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959392 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 5BCC1ECAAD1 for ; Tue, 30 Aug 2022 13:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbiH3NzC (ORCPT ); Tue, 30 Aug 2022 09:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbiH3Nyg (ORCPT ); Tue, 30 Aug 2022 09:54:36 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E63113E90 for ; Tue, 30 Aug 2022 06:54:31 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id k6-20020a05600c1c8600b003a54ecc62f6so6188532wms.5 for ; Tue, 30 Aug 2022 06:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=o/LdOqUzCNHGwvswaHVae5HSWOMYANZGKbhv6ZUrQS4=; b=cxXXUx6386mAIEAU5+sOXNvqZD5IXu+1mhIhcIq6AmLrKI2wMYYq1/iD/kKawtSHbt xEUWvVDDqOK/qdOhlKx1zbcS4O+P/NiMgjZ4aXUWg+tDLM1CBNeO47Cq1XeTbvFFt8Qj B1cxUehlZXN2TtDjt7i/qb68QBp74aOp9kcjj2qFTHaLvkNYkKPPZ22DDPR1xYLJcc3l N8xXlk57v7QhrEY1BvKSUx2BGa2e+dC/hA2OWS3EmuGfmliLONedTQs1U35aEUwdoT9B QhF9XdVjZ7NMFk2BZqSY10w8luxP9NGREDUpjumdzedeE64/juaxd4Bi4w6BxfC7uUNn Ya1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=o/LdOqUzCNHGwvswaHVae5HSWOMYANZGKbhv6ZUrQS4=; b=eDU0wWUBNTvjJT5VO5cCzt8ygfay65ZceQAP7BrL1AdePDseZDCrj78yf/odse3YL0 5ZcIYzaOChCwmYT0KTVoacNv4i89t2pl9rSAU6ei7rd5Z3bFX/R/ZgiWD3VbiVjZQABl mKlmli0jE4lPn/6d9O1rUx66QYuNGudI/oN0mJyKayiZuLy3alnbQlhOVdHqqI1HtGAL QJHVA6pbwHktGi++dF1ItNos2lCjP5Hsw6dDqR6ZpfIbo0ZxukEGoCdIUNpKukoiRyyT nf8LfbLUcWu6Slva4Gq1/7B4Uxltvmr2l06CL4szekNHkPddRYeChOVqhzrPjSgf8SMx okGA== X-Gm-Message-State: ACgBeo0FiEDWWlyC5AbReTU1cA3yjRO9e0/YUOky2lbbQJkT/qdcNOEr HXnjRR4sHL6rszTcejq+dBfdxiWtKKY= X-Google-Smtp-Source: AA6agR76/Wz0WmakOEcDteAbibTQRb7yl16tdMrH4AZ2dxDa1W+BUEvRCc4sHiqid3xp8YG//pH2Sw== X-Received: by 2002:a05:600c:1912:b0:3a5:f4fc:cd40 with SMTP id j18-20020a05600c191200b003a5f4fccd40mr9869450wmq.205.1661867668889; Tue, 30 Aug 2022 06:54:28 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b16-20020a05600c4e1000b003a5ad7f6de2sm12497204wmq.15.2022.08.30.06.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 06:54:28 -0700 (PDT) Message-Id: <54d25d991b09219f6992dc3e8c102ce1ccef6313.1661867664.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 13:54:23 +0000 Subject: [PATCH 2/3] t3701: test the built-in `add -i` regardless of NO_PERL Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin The built-in `git add --interactive` does not require Perl, therefore we can safely run these tests even when building with `NO_PERL=LetsDoThat`. Signed-off-by: Johannes Schindelin --- t/t3701-add-interactive.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index b354fb39de8..8d16cd45821 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -7,9 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh -if ! test_have_prereq PERL +if test_have_prereq !ADD_I_USE_BUILTIN,!PERL then - skip_all='skipping add -i tests, perl not available' + skip_all='skipping add -i (scripted) tests, perl not available' test_done fi From patchwork Tue Aug 30 13:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959393 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 0AF60ECAAD1 for ; Tue, 30 Aug 2022 13:55:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbiH3NzF (ORCPT ); Tue, 30 Aug 2022 09:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231307AbiH3Nyi (ORCPT ); Tue, 30 Aug 2022 09:54:38 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F60D10FB for ; Tue, 30 Aug 2022 06:54:32 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id e13so13421792wrm.1 for ; Tue, 30 Aug 2022 06:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=IMltBZ4M0IkpvwXFSb8AG5YF2NMVr6CiU5ni2/ATH48=; b=Q1G+in45TGMbhcW4xPfRLB4n+Lok/cU6x7iDmt2rBnv83nxqAgcKSxQuczWRFsfJFA UScTvwPabkbtSRfG1/iMn61sUG8PkxeHn9W9q9Q4vmyatd95auOY5V69lTHqkllDW79S fQPgO95c08jS+8Mivuz25cSfS5hxs4f2zzo1o1Cv9qVO+ogYXbdEyHVpYJltk4gIyddT zZsHEd76ghacyxT89W22alKhfq1qGUtDhmU587mntJbfYMKhZiYd42l7dGGBz3dwQAdC ELoUhBIeQbpClTckrNJgRWgRa/WIroIFCopS1VbUlxfvJnDmYY+hI1GXYFI2vQWZlIxO ai8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=IMltBZ4M0IkpvwXFSb8AG5YF2NMVr6CiU5ni2/ATH48=; b=d0wemjjJAReVW6zIYyWN7V/sLgSge3eGJ9wef3glZPhVRIPIIZAW9GshXQM9El+L+Z i/44v+fIoTTt9mobOCv1kL8jhQ40Jm6P44G7KcglqwlY8T8TAghV7/9VD5th3vgmUcvZ n/MJtVuSgAoCDHRQhz0hBfmknC43GWcbJjVDd1XIc/70qQHazDnP8+TNiajvMAA9+XNZ 0Jw4Lc3S/xGAmqmLz3Gv0YJjMWyTq1ypLSJWEaJcZzHawOuDhW0VyS1WAA7fcw5ZbYGb M1CPGhKQoOMjRx7tLhoBYDfvFamWUP+rdSgNdpg9NMbAP2yaonux8n+4YYVS2nMY0aTH 8yNQ== X-Gm-Message-State: ACgBeo20s7T3nXxmtM8lE1zLhIkmgV3uVA1ZBN62tLVzg05xjDwtc44m R40xtv3Zh+0q1tx8a+6LUR/HGodaBds= X-Google-Smtp-Source: AA6agR6oIKOFjOoyYoK4lAxZM6GVzaQggFEB/HnqGxdtZzZiNiHoIJODs/ashKbIhRr8dIB3m1hIPA== X-Received: by 2002:a05:6000:1789:b0:225:7557:94f9 with SMTP id e9-20020a056000178900b00225755794f9mr8943392wrg.635.1661867670361; Tue, 30 Aug 2022 06:54:30 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o19-20020a5d58d3000000b00226de10c0c2sm4448144wrf.15.2022.08.30.06.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 06:54:29 -0700 (PDT) Message-Id: <736f2dde6918822e5f8234dc8cddcb94aa3f92ac.1661867664.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 13:54:24 +0000 Subject: [PATCH 3/3] t6132(NO_PERL): do not run the scripted `add -p` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin When using the non-built-in version of `git add -p` in a `NO_PERL` build, we expect that invocation to fail. However, when b02fdbc80a4 (pathspec: correct an empty string used as a pathspec element, 2022-05-29) added a test case to t6132 to exercise `git add -p`, it did not add appropriate prereqs (which admittedly did not exist back then). Let's specify the appropriate prereqs. Signed-off-by: Johannes Schindelin --- t/t6132-pathspec-exclude.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/t/t6132-pathspec-exclude.sh b/t/t6132-pathspec-exclude.sh index 9fdafeb1e90..cada952f9ae 100755 --- a/t/t6132-pathspec-exclude.sh +++ b/t/t6132-pathspec-exclude.sh @@ -293,7 +293,11 @@ test_expect_success 'add with all negative' ' test_cmp expect actual ' -test_expect_success 'add -p with all negative' ' +test_lazy_prereq ADD_I_USE_BUILTIN_OR_PERL ' + test_have_prereq ADD_I_USE_BUILTIN || test_have_prereq PERL +' + +test_expect_success ADD_I_USE_BUILTIN_OR_PERL 'add -p with all negative' ' H=$(git rev-parse HEAD) && git reset --hard $H && git clean -f &&