From patchwork Mon Feb 15 15:50:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12088765 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=-15.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,USER_AGENT_GIT 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 9EF7CC433E6 for ; Mon, 15 Feb 2021 16:05:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6385564DEB for ; Mon, 15 Feb 2021 16:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232803AbhBOQDk (ORCPT ); Mon, 15 Feb 2021 11:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232079AbhBOPvR (ORCPT ); Mon, 15 Feb 2021 10:51:17 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4599DC061222 for ; Mon, 15 Feb 2021 07:50:36 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id o10so4462341wmc.1 for ; Mon, 15 Feb 2021 07:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EWehV4mXxzX5rQqkLgKeK3M1OZAWlbGKq7lUzT82qJs=; b=B1cpa3FsyrjI8stF3bwq2M8IhproPaeZNjXoEUGqqCsFQtwlEwUIoRZZCNZlcLz2YK eM1pPUsdXYyopCz7TfgTumdbCRjn5xRGBzclQJXrFbQGWyxxljyXCi99Fpfu6bAwgCZq ZwpeBkrxSkb/cKNwfK+zA9TQM7MO5rEV60daK0s89QuRE0mq+mA464YAGQv6vVtpUCtt sq3/26dAtr4FwUaTdYc9QOtMwnVi/28lVkxkqWxGvuPUEBsETZO7fBKoZ2dYMkNQNxJk wZ6U9XqihJwmiJkNxv/jTkeeicXRgFcLEpVHSaFU5pWW/Ql5XVgwXG27dy86dVAqV9yo CTBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EWehV4mXxzX5rQqkLgKeK3M1OZAWlbGKq7lUzT82qJs=; b=HISWZb4LiNukYa9QC1pEPUkZKzyzdG+la9oiL7STah1bPf0Yroqnnl8W6HgQqeUAku 2HqjAm3GFAZzrC4cURwFGfQhU1v4SEhOHylaX8fe8lk7gN7Dss2f5RxAkFUJd+t695zv recwpbMuAaHzd8BDaVe69ac2WzU4fuoQKH83tq1lFYmHDkazmJceRZZfSL/sMY4O/oI0 JDKKdtNlPDxpcdnt6CmGuaKJsiwWYvY1Ft6KfcaqTF6B1CqwIhjX+yyFQWYJNvEYByb1 vwwFVC4hHGBc+CfECkrMVQUiV/+N/6AXZT0wFb6E8MLivvH4pomLOfHCLKFvzvtoZsj1 UYDg== X-Gm-Message-State: AOAM531HB0defebzX733H/IbPvly2EMK+O4G8qxUakHxZeOxMG96F90F oQzHJQzHqo23NvnTOXpbhpO8/vVeVeWD/w== X-Google-Smtp-Source: ABdhPJxcNppUFVHZM5Xyq4FvHo9zPMwrLDaQ66o7Qj1E1dsGlTCFu2H+G4yjwnJJTlnqS8Ie3wHXoQ== X-Received: by 2002:a1c:6308:: with SMTP id x8mr14915626wmb.78.1613404234728; Mon, 15 Feb 2021 07:50:34 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 75sm9672617wma.23.2021.02.15.07.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 07:50:34 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Vegard Nossum , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/2] diff: do not display hunk context under -W Date: Mon, 15 Feb 2021 16:50:19 +0100 Message-Id: <20210215155020.2804-2-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix what I believe to be a long-standing bug in how "-W" interacts with displaying the hunk context on the @@ line: It should not be displayed at all under -W. The long-standing semantics of how -W works and interacts with -U are rather easy to reason about: * -W extends the context line up to the start of the function. With userdiff this means the language-aware regex rules in userdiff.c, or user-supplied rules. * -U, which defaults to -U3 shows at least lines of context, if that's greater than what we'd extend the context to under -W then -U wins. * When showing the hunk context we look up from the first line we show of the diff, and find whatever looks like useful context above that line. Thus in e.g. the xdiff/xemit.c change being made in this commit we'll correctly show "xdl_emit_diff()" in the hunk context under default diff settings. But if we viewed it with the -W option we'd show "is_empty_rec()", because we'd first find the "xdl_emit_diff()" context line, extend the diff to that, and then would go look for context to show again. I don't think this behavior makes any sense, our context in this case is what we're guaranteed to show as part of the diff itself. The user already asked us to find that context line and show it, we don't need to then start showing the context above that line, which they didn't ask for. This new behavior does give us the edge case that if we e.g. view the diff here with "-U150 -W" we'd previously extend the context to the middle of the "is_func_rec()" function, and show that function in the hunk context. Now we'll show nothing. I think that change also makes sense. We're showing a change in the "xdl_emit_diff()" function. That's our context for the change. It doesn't make sense with -W to start fishing around for other context. Arguably in that case we could save away the context we found in the "XDL_EMIT_FUNCCONTEXT" in "xdl_emit_diff()" and show that if we end up extending the diff past the function, either because of a high -U value, or because our change was right at the start. I wouldn't really mind if we did that, perhaps it would be a useful marker with high -U values to remind the user of what they're looking at, but I also don't see the usefulness in practice, so let's punt that for now. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/diff-options.txt | 4 ++++ t/t4015-diff-whitespace.sh | 2 +- t/t4018-diff-funcname.sh | 7 +++++++ xdiff/xemit.c | 4 +++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index e5733ccb2d..8ca59effa7 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -759,6 +759,10 @@ endif::git-format-patch[] The function names are determined in the same way as `git diff` works out patch hunk headers (see 'Defining a custom hunk-header' in linkgit:gitattributes[5]). ++ +When showing the whole function for context the "@@" context line +itself will always be empty, since the context that would otherwise be +shown there will be the first line of the hunk being shown. ifndef::git-format-patch[] ifndef::git-log[] diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 8c574221b2..0ffc845cdd 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -2133,7 +2133,7 @@ test_expect_success 'combine --ignore-blank-lines with --function-context 2' ' --ignore-blank-lines --function-context a b >actual.raw && sed -n "/@@/,\$p" actual && cat <<-\EOF >expect && - @@ -5,11 +6,9 @@ c + @@ -5,11 +6,9 @@ function 1 2 diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 80f35c5e16..f3374abd98 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -91,6 +91,13 @@ test_diff_funcname () { fi ' && + test_expect_success "$desc -W" ' + git diff -U0 -W "$what" >W-U0-diff && + echo >W-U0-expected && + last_diff_context_line W-U0-diff >W-U0-actual && + test_cmp W-U0-expected W-U0-actual + ' && + test_expect_success "$desc (accumulated)" ' git diff -U1 "$what".acc >diff && last_diff_context_line diff >actual.lines && diff --git a/xdiff/xemit.c b/xdiff/xemit.c index 9d7d6c5087..02b5dbcc70 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -274,7 +274,9 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, */ if (xecfg->flags & XDL_EMIT_FUNCNAMES) { - get_func_line(xe, xecfg, &func_line, + get_func_line(xe, xecfg, + xecfg->flags & XDL_EMIT_FUNCCONTEXT + ? NULL : &func_line, s1 - 1, funclineprev); funclineprev = s1 - 1; } From patchwork Mon Feb 15 15:50:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12088763 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=-15.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,USER_AGENT_GIT 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 BA094C43603 for ; Mon, 15 Feb 2021 16:05:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A281664E51 for ; Mon, 15 Feb 2021 16:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232820AbhBOQDo (ORCPT ); Mon, 15 Feb 2021 11:03:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232114AbhBOPvm (ORCPT ); Mon, 15 Feb 2021 10:51:42 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E6AC061224 for ; Mon, 15 Feb 2021 07:50:37 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id g6so9447386wrs.11 for ; Mon, 15 Feb 2021 07:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y+OHjJIpz4gQDWXJCfmjn7hKqWx9ySgKfEtGy5rLasw=; b=sL3ulTfoe/p718rv1Dpiv9P3WkKe97pG9Sl3/OfBoEc9asW9QkmEiixYJFtwf4onsw hRdCddhi2Kis7zzZZf6ukkB1HEh/JXq6h6LxfDw5hjCjNXzcW3/22uNC2O4VITj7t7Jd Tm+TRXpKfggpBVy/DtbyAtqX/xfh+YIwJPtzkevJeP4/Bz/oYk7UQtNXERZ+VxSb25js BEygKrQfHBNaWWC4Q5+NgcS+KO+xrv7nEkrLAbJg4XqwkJX+uovNdunPaXgaJe2fCKC0 lk0hu/lUVtQ8z0wJ99To7QFUJxxVBBgPuGUP5bZjoNyqRqAiMql0FvKuvh6We1HcMknf 8pLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y+OHjJIpz4gQDWXJCfmjn7hKqWx9ySgKfEtGy5rLasw=; b=G+Afg905bK+5L9rZD7Fc8Y4R5aMfDjd2wttANArLfyeacvA+X8vM7BDivKEzS4f0jO +UjNCsOHMoCS47MzQsaIpQgdyBlYeNOd6AoUHX4L8TDSdhbXcrVlfrlR9XTtMJTanJ3V YzVPapaWpgdaK4R8dCEFK4zzp/Mh2b2QM5/PfF5GVBjRxPqDXkSYK7qHMLJpnQhEI7Ga 1ENUoRFfj4aXhxVR2VhgSLGB/z2HO9lmHQVxjlXgoEaJcQkJsLIGiOqKLrDB3uxLJht+ cBX5fNRCJf1YHaZoTvdcKCqunSNzpZy37QmGYOOue8j/mMtzIeTBLggN1lQCasiQilrd KCAA== X-Gm-Message-State: AOAM532TpRJLXwhMg9BdDw9K/CDWQCmG0e0uueYYznnfQfzEqokXkS9G 5mUxs9WxW1NyHa0SCfpy3iq1BAGSB3XQuQ== X-Google-Smtp-Source: ABdhPJzBEDe5sRznuGBdHe+1jJjQnpyhm98zH5FXMxACg1MNdwhl8Okz9vPTvATZ1TF3kQp7Iorfmw== X-Received: by 2002:adf:9546:: with SMTP id 64mr20074396wrs.247.1613404235578; Mon, 15 Feb 2021 07:50:35 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 75sm9672617wma.23.2021.02.15.07.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 07:50:34 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Vegard Nossum , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/2] diff: test and document -W interaction with -U Date: Mon, 15 Feb 2021 16:50:20 +0100 Message-Id: <20210215155020.2804-3-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/diff-options.txt | 8 ++++++++ t/t4018-diff-funcname.sh | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 8ca59effa7..3c19c78616 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -88,6 +88,11 @@ endif::git-log[] --unified=:: Generate diffs with lines of context instead of the usual three. ++ +Under `-W` generates diffs with at least lines of context, if the +number is lower than the context `-U` would extend the diff to then +`-U` takes precedence. + ifndef::git-format-patch[] Implies `--patch`. endif::git-format-patch[] @@ -763,6 +768,9 @@ endif::git-format-patch[] When showing the whole function for context the "@@" context line itself will always be empty, since the context that would otherwise be shown there will be the first line of the hunk being shown. ++ +See the documentation for `-U` above for how the two options +interact. ifndef::git-format-patch[] ifndef::git-log[] diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index f3374abd98..38dc029917 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -98,6 +98,11 @@ test_diff_funcname () { test_cmp W-U0-expected W-U0-actual ' && + test_expect_success "$desc -W interaction with -U" ' + git diff -U9001 "$what" >W-U9001-diff && + grep "^@@ -1," W-U9001-diff + ' && + test_expect_success "$desc (accumulated)" ' git diff -U1 "$what".acc >diff && last_diff_context_line diff >actual.lines && From patchwork Wed Feb 24 19:50:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102347 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=-15.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,USER_AGENT_GIT 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 08281C433E6 for ; Wed, 24 Feb 2021 19:52:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D028A64F0F for ; Wed, 24 Feb 2021 19:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234480AbhBXTw5 (ORCPT ); Wed, 24 Feb 2021 14:52:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232392AbhBXTwg (ORCPT ); Wed, 24 Feb 2021 14:52:36 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65681C061788 for ; Wed, 24 Feb 2021 11:51:56 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id t15so3022040wrx.13 for ; Wed, 24 Feb 2021 11:51:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QfWIlWwkjr8ie94frouiQ0xnqcBC5QYrhNbYMgvsYU8=; b=bBAG0zRewXgn39GXtf+D7ESk6q1HFgF0/+k9MLixUYRN8KjWCBrEg1wcY1W6UO7MLJ hKXHmdfUJ+sSS9Nm0tfKzQCzN3naRIFinK2jgCRUMe8iyvqC/MwrJS7236fCpxrT4GkP r629Eo9ZEqnqcbR2DleriOwu2XO8VCborgtxFzb6XvCcl706aDqNnhSOljb5cv0K2ZM+ cupSzQMRLuq4cpfo3UebQj24Wqt189fHomON/TQQb/rnWvBiKgOVF/WxN3/dAAASsCe9 GJTV4+NFOpXa2UTDCG+zyMShfWBORFmgR2EOmnaqM9uQPHsJUzvDf7JnW5v3b69ISAle LUMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QfWIlWwkjr8ie94frouiQ0xnqcBC5QYrhNbYMgvsYU8=; b=pxd3aqIWZCjI/jFAV2pcUcs/fXH/3TP6xJBQXIRwF1C+X2hJD6lv3d3oEGa8tvLLkt XeZpE9qG8oXexJPEncqVQAzdFQUk/TIogZFIipTYyvXRR72LOPi/tu42UbEDap6vZhcY XKIV1s/1rL0gGGo0nrN+Yf8XfAED/6w0M5s8I3Uw88tk6inPKIbR7mf8OxljoKtq/9Ap cx08JpD9zPxCgEvsqDfWbFxUz0+vOlB+EL6YsNWyD7DfJE+VkWYVTvCgSLW9EmdRxFOo HpIpYOiovW6vdW8dRji9VBBsV1IfTi6AEtRnXUhSl6ccgw4Uuvvbj+tFUVg7SYckjUh3 QM8g== X-Gm-Message-State: AOAM532ub9wWE1DZiG/FtJZaq29on9MQmI7T5quxV3wClY842jBOXH+a pHZEAkZHl6t+kmvQ85Otb1fGzEeF3RwAjA== X-Google-Smtp-Source: ABdhPJxfLYl51UHlOKJFLXIwxUij86EH+kRHqj4AsnQatMRB5pELDUsq10FSOhQBMJ+9VHp3zUB6LQ== X-Received: by 2002:adf:f70a:: with SMTP id r10mr20824076wrp.61.1614196314820; Wed, 24 Feb 2021 11:51:54 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:51:54 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 03/35] userdiff style: declare patterns with consistent style Date: Wed, 24 Feb 2021 20:50:57 +0100 Message-Id: <20210224195129.4004-4-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change those patterns which were declared with a regex on the same line as the "PATTERNS()" line to put that regex on the next line, and add missing "/* -- */" separator comments between the pattern and word_regex. Signed-off-by: Ævar Arnfjörð Bjarmason --- userdiff.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/userdiff.c b/userdiff.c index c92cbcc0540..c7aaf7094f8 100644 --- a/userdiff.c +++ b/userdiff.c @@ -44,7 +44,9 @@ PATTERNS("bash", /* -- */ /* Characters not in the default $IFS value */ "[^ \t]+"), -PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", +PATTERNS("bibtex", + "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", + /* -- */ "[={}\"]|[^={}\" \t]+"), PATTERNS("cpp", /* Jump targets or access declarations */ @@ -121,7 +123,9 @@ IPATTERN("fortran", * they would have been matched above as a variable anyway. */ "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?" "|//|\\*\\*|::|[/<>=]="), -IPATTERN("fountain", "^((\\.[^.]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$", +IPATTERN("fountain", + "^((\\.[^.]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$", + /* -- */ "[^ \t-]+"), PATTERNS("golang", /* Functions */ @@ -132,7 +136,9 @@ PATTERNS("golang", "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.eE]+i?|0[xX]?[0-9a-fA-F]+i?" "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&\\^=?|&&|\\|\\||<-|\\.{3}"), -PATTERNS("html", "^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$", +PATTERNS("html", + "^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$", + /* -- */ "[^<>= \t]+"), PATTERNS("java", "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" @@ -144,6 +150,7 @@ PATTERNS("java", "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*", + /* -- */ "[^<>= \t]+"), PATTERNS("matlab", /* @@ -152,6 +159,7 @@ PATTERNS("matlab", * that is understood by both. */ "^[[:space:]]*((classdef|function)[[:space:]].*)$|^(%%%?|##)[[:space:]].*$", + /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"), PATTERNS("objc", /* Negate C statements that can look like functions */ @@ -212,13 +220,15 @@ PATTERNS("php", "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+" "|[-+*/<>%&^|=!.]=|--|\\+\\+|<<=?|>>=?|===|&&|\\|\\||::|->"), -PATTERNS("python", "^[ \t]*((class|(async[ \t]+)?def)[ \t].*)$", +PATTERNS("python", + "^[ \t]*((class|(async[ \t]+)?def)[ \t].*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"), /* -- */ -PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$", +PATTERNS("ruby", + "^[ \t]*((class|module|def)[ \t].*)$", /* -- */ "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." From patchwork Wed Feb 24 19:50:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102351 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=-15.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,USER_AGENT_GIT 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 33A26C433DB for ; Wed, 24 Feb 2021 19:53:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2F5464EDD for ; Wed, 24 Feb 2021 19:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234782AbhBXTxS (ORCPT ); Wed, 24 Feb 2021 14:53:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232746AbhBXTwh (ORCPT ); Wed, 24 Feb 2021 14:52:37 -0500 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 269A9C06178A for ; Wed, 24 Feb 2021 11:51:57 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id r3so3028374wro.9 for ; Wed, 24 Feb 2021 11:51:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rVQUS916SkOLnrvHQDUbKibSU9DW/B5XLZlxl5YQPlw=; b=oFMGMuaO9TiSxrFx3PFcKYtnv+SI4LKk+DHDDw/IrkMUp3s7/ZBfZDJAAGgBRDEn8R HB8S7wxJR8Dyeg2IxN0lXzGOKQrkv2PkXh11U+Cz1q1EwQQMSXaaIPzzPc0AJ7g6WPbv 3wwj5C2Fx+aIdMPbbOjzsJuCPhqoucnlTnAd4or2SO/Y9gJ2Wfxd/m9r3TQTY8c0hYeJ q6rhjUITf1YMbAwwdFf314QLTUZRo6K30YzfqlOLjtIHYaRoPayQQg3xO2/1GztVWzfv adJNLKbFSZKTxqw1/lxjwTLzixoLoxVJKJXF6p5fZBFrtegItjyZ5QjEbsARt/RQfCIe No6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rVQUS916SkOLnrvHQDUbKibSU9DW/B5XLZlxl5YQPlw=; b=cL4XEBgH9KD8IfqdCiStmHbQePjO9dC4nYfjQhbWcQR3ObILjBqde8X7bL2AmooSPX 9PcfjdRUKwUpfsnJTTIcfFX5j/7W9zj+/dfBZhmCvHAPbtlHx+UtXXVZzASjxz7QjPTR Utc2aIX9GYDy5QxPKBiSNfrBgesbAfNsUo/zQ+eTRf74MFKkvxLi0zRrtF03ollVK37t 0PMBdc9EkjP3gDHHnfq06ZDYwdkWWwq+10WdTU/j/5QlnVMxfuDbV5szxS44Gr9VRP3W l8OlFS4ZXFgZpXjyz9w2DkG5a2qUFi+A+VtfrmgnbYCwXTP8ixqmvXfv0BauKlNjDX5q hyKg== X-Gm-Message-State: AOAM532HjzKPSb3RwNmYTw/8SSjdNXcMpv8k4f41S7JBW6gAuIlqGvwM vs31vEGY1JgfPGXcOaCjPTEAVLY3Y8J6FQ== X-Google-Smtp-Source: ABdhPJw2kkY9snYgVI0BdB4jRMZo7k1Buj4T8DroSwqixTV8maKxrrqgT+3w/j6AZ+1DQD2YQ4D9Zw== X-Received: by 2002:a5d:458a:: with SMTP id p10mr24037776wrq.347.1614196315682; Wed, 24 Feb 2021 11:51:55 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:51:55 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 04/35] userdiff style: normalize pascal regex declaration Date: Wed, 24 Feb 2021 20:50:58 +0100 Message-Id: <20210224195129.4004-5-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Declare the pascal pattern consistently with how we declare the others, not having "\n" on one line by itself, but as part of the pattern, and when there are alterations have the "|" at the start, not end of the line. Signed-off-by: Ævar Arnfjörð Bjarmason --- userdiff.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/userdiff.c b/userdiff.c index c7aaf7094f8..10a02d36209 100644 --- a/userdiff.c +++ b/userdiff.c @@ -175,9 +175,8 @@ PATTERNS("objc", "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), PATTERNS("pascal", - "^(((class[ \t]+)?(procedure|function)|constructor|destructor|interface|" - "implementation|initialization|finalization)[ \t]*.*)$" - "\n" + "^(((class[ \t]+)?(procedure|function)|constructor|destructor|interface" + "|implementation|initialization|finalization)[ \t]*.*)$\n" "^(.*=[ \t]*(class|record).*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" From patchwork Wed Feb 24 19:50:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102353 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=-15.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,USER_AGENT_GIT 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 A4321C433E0 for ; Wed, 24 Feb 2021 19:53:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 702C864EF5 for ; Wed, 24 Feb 2021 19:53:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234917AbhBXTxW (ORCPT ); Wed, 24 Feb 2021 14:53:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234495AbhBXTxQ (ORCPT ); Wed, 24 Feb 2021 14:53:16 -0500 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 407A0C06178B for ; Wed, 24 Feb 2021 11:51:58 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id h98so3027456wrh.11 for ; Wed, 24 Feb 2021 11:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sMx0HZwcMfXSaewuB57svVW+0gB/b96yQanzPvv2DB0=; b=t749Sf4r5a/Mv9rJM1a+6VAbZ3O/dtUsBLAGvcVY8qSQOQkAg60qJQjPcuxisTfVi9 L2npMdl5/SAAh6fTmwbyfowyVBfC+5mHCXlIK6ga29ml7aVV3XAScre2/vOL7n3/9nHf N94N8zrpdTXiZY/oqiW1qpmWNJ/e6pFM/dUAHe0t3lASXSAGnnyS7jml7+8EReeUQN0e mtKcf6luPBG3xgAJ883RIRJLitoWofuA1MvRxEDU6nl+K064q8QfQaZBZ7Yj2/RDR8zr PQ8te3A/OQLl2HqUw9bom4nKha/ob4d9AIsRHLbrcpAK6OQS5InVJS3Aq6l7jyYv2NSB N8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sMx0HZwcMfXSaewuB57svVW+0gB/b96yQanzPvv2DB0=; b=SKCpIdqplWaQoHTc7kIovpYnMD60wC3QZgqYLARCW2Mv/99zDjLz5zfOCiU8kVCd6U fXtTOErzsvyaBnGezu9T5OZP+nUWwIebi8GSg0IpjJyPmE2CyDd/xS0IJjEs+N4c7hU/ RDiHcSo7r0F8NZzsZSkqHP3jTKeF48rDCdU9q6/2cLNuYvYdT3ayLoGak6MSPsgwUHvi KYt6E3t5iOTdrtbfB5TylEKTHh/M3PPnCl7vTRhBmA3X7lnX/rqd0ay2DEZu8YHirH3G O5DkG7tDx6taIDzJQhXrMrqBHtd+UNJaqmZHuw1rjAw5CgNVQB1qN5g2L4RYxyKuvcc6 ePpA== X-Gm-Message-State: AOAM530bzQGphZW/xxkOjqAsYHkH74MtUnoA01uTxE/TYd9RNgxNUjNm haU9yD5aiJaM1CKtrzzoVIcCrWIux0yzYA== X-Google-Smtp-Source: ABdhPJyP2CEespeDwCMSXCVPbWYT6GrVOUq84hfu6qlq82XniocBR+cN7SVnwJRYuPYkQ4UcfpSZ9w== X-Received: by 2002:a5d:47af:: with SMTP id 15mr33316596wrb.205.1614196316724; Wed, 24 Feb 2021 11:51:56 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:51:56 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 05/35] userdiff: add and use for_each_userdiff_driver() Date: Wed, 24 Feb 2021 20:50:59 +0100 Message-Id: <20210224195129.4004-6-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor the userdiff_find_by_namelen() function so that a new for_each_userdiff_driver() API function does most of the work. This will be useful for the same reason we've got other for_each_*() API functions as part of various APIs, and will be used in a follow-up commit. Signed-off-by: Ævar Arnfjörð Bjarmason --- userdiff.c | 61 +++++++++++++++++++++++++++++++++++++++++++----------- userdiff.h | 15 ++++++++++++++ 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/userdiff.c b/userdiff.c index 10a02d36209..55f4f769bd3 100644 --- a/userdiff.c +++ b/userdiff.c @@ -259,20 +259,32 @@ static struct userdiff_driver driver_false = { { NULL, 0 } }; -static struct userdiff_driver *userdiff_find_by_namelen(const char *k, size_t len) +struct for_each_userdiff_driver_cb { + const char *k; + size_t len; + struct userdiff_driver *driver; +}; + +static int userdiff_find_by_namelen_cb(struct userdiff_driver *driver, + enum userdiff_driver_type type, void *priv) { - int i; - for (i = 0; i < ndrivers; i++) { - struct userdiff_driver *drv = drivers + i; - if (!strncmp(drv->name, k, len) && !drv->name[len]) - return drv; - } - for (i = 0; i < ARRAY_SIZE(builtin_drivers); i++) { - struct userdiff_driver *drv = builtin_drivers + i; - if (!strncmp(drv->name, k, len) && !drv->name[len]) - return drv; + struct for_each_userdiff_driver_cb *cb_data = priv; + + if (!strncmp(driver->name, cb_data->k, cb_data->len) && + !driver->name[cb_data->len]) { + cb_data->driver = driver; + return -1; /* found it! */ } - return NULL; + return 0; +} + +static struct userdiff_driver *userdiff_find_by_namelen(const char *k, size_t len) +{ + struct for_each_userdiff_driver_cb udcbdata = { .k = k, .len = len, .driver = NULL }; + + for_each_userdiff_driver(userdiff_find_by_namelen_cb, + USERDIFF_DRIVER_TYPE_UNSPECIFIED, &udcbdata); + return udcbdata.driver; } static int parse_funcname(struct userdiff_funcname *f, const char *k, @@ -373,3 +385,28 @@ struct userdiff_driver *userdiff_get_textconv(struct repository *r, return driver; } + +int for_each_userdiff_driver(each_userdiff_driver_fn fn, + enum userdiff_driver_type type, void *cb_data) +{ + int i, ret; + if (type & (USERDIFF_DRIVER_TYPE_UNSPECIFIED | USERDIFF_DRIVER_TYPE_CUSTOM)) { + + for (i = 0; i < ndrivers; i++) { + struct userdiff_driver *drv = drivers + i; + ret = fn(drv, USERDIFF_DRIVER_TYPE_CUSTOM, cb_data); + if (ret) + return ret; + } + } + if (type & (USERDIFF_DRIVER_TYPE_UNSPECIFIED | USERDIFF_DRIVER_TYPE_BUILTIN)) { + + for (i = 0; i < ARRAY_SIZE(builtin_drivers); i++) { + struct userdiff_driver *drv = builtin_drivers + i; + ret = fn(drv, USERDIFF_DRIVER_TYPE_BUILTIN, cb_data); + if (ret) + return ret; + } + } + return 0; +} diff --git a/userdiff.h b/userdiff.h index 203057e13e5..fe14014a775 100644 --- a/userdiff.h +++ b/userdiff.h @@ -21,6 +21,13 @@ struct userdiff_driver { struct notes_cache *textconv_cache; int textconv_want_cache; }; +enum userdiff_driver_type { + USERDIFF_DRIVER_TYPE_UNSPECIFIED = 1<<0, + USERDIFF_DRIVER_TYPE_BUILTIN = 1<<1, + USERDIFF_DRIVER_TYPE_CUSTOM = 1<<2, +}; +typedef int (*each_userdiff_driver_fn)(struct userdiff_driver *, + enum userdiff_driver_type, void *); int userdiff_config(const char *k, const char *v); struct userdiff_driver *userdiff_find_by_name(const char *name); @@ -34,4 +41,12 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate, struct userdiff_driver *userdiff_get_textconv(struct repository *r, struct userdiff_driver *driver); +/* + * Iterate over each driver of type userdiff_driver_type, or + * USERDIFF_DRIVER_TYPE_UNSPECIFIED for all of them. Return non-zero + * to exit from the loop. + */ +int for_each_userdiff_driver(each_userdiff_driver_fn, + enum userdiff_driver_type, void *); + #endif /* USERDIFF */ From patchwork Wed Feb 24 19:51:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102355 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=-15.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,USER_AGENT_GIT 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 31178C433DB for ; Wed, 24 Feb 2021 19:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB24264EF5 for ; Wed, 24 Feb 2021 19:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235053AbhBXTxZ (ORCPT ); Wed, 24 Feb 2021 14:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234570AbhBXTxQ (ORCPT ); Wed, 24 Feb 2021 14:53:16 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00711C06178C for ; Wed, 24 Feb 2021 11:51:58 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id u14so3051269wri.3 for ; Wed, 24 Feb 2021 11:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CJfrO6oxVRVCU+9c3QNry2H+uZwTWYg5ucIJmHd2vOA=; b=owNs0Nqp0wklv2VaqXVMXpnHbp2wNNXdSCUklKP0E5dU9EdzGMof8SPi0mySXc0lrN C7Ok/e6nPWo88f5RbVPylXej3eKTTv0O9itQBVBJNf/ckPQ62NIGUrZUCmheBe/qw/am qc6ygDED/gGChqhfjGi7h17UQQEIVR/KLk5cl96jgxJn3zqBVExH/enRGMp/TQX6Dz7q 2VEeY/JmwxCSn1BenfAGfTcUdQFR/7eFzp5UvFAw1x1m98Ymo7TO6kgRfCPxVSxu1Nyy +fAVjl7v5TGOG8kL0atbRH0o/9FldweVJhB/Eg36mTwgobpXFmuFEGebs08RYPvAzdNq tLIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CJfrO6oxVRVCU+9c3QNry2H+uZwTWYg5ucIJmHd2vOA=; b=FsA5dcwFOqzjwnEx0e+loxv7/GcLwTM2VWZhcRHP6u3FkbvLbpRvjYC5EvsLKYl7D9 RwvZimS3+Bot9q8XubeacZA3CpntzlS/8b6wqo272DDFXZTHKC84HX//qrYnvQOM8QlI RyRMlPINxzDDro9k8c1YCWTHUzdKMX4UEDKur2xLVkhuovN0n87jIY5sHbYo1SC2ANnj mn93o3S3O8qNN5V7T8EiayLrBi/zKlKQBjDy0bpQORFJYVE8JvhafsfosfMysbbam6zb ExjcMdguU0nrM2Lmw68Y6iOued17CMXfoxO217CcZF5WFynBYvg3PAdKeow/mZhKhzip XQpQ== X-Gm-Message-State: AOAM531HSzrtGS85XlryIkVJsjBG9CP8MUUU1DO667vW7r5tWvR442HL RDf/gZNxgyDa3JPC45x3oYpXNgKtnpzsbg== X-Google-Smtp-Source: ABdhPJzWWObWD/wgqc/GK+m1LJFhI62Srvywp6Jk0vOOltlke4Ewk6SQB7SXIutU5XxHXjq3mWOxyw== X-Received: by 2002:adf:9564:: with SMTP id 91mr32313025wrs.207.1614196317501; Wed, 24 Feb 2021 11:51:57 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:51:57 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 06/35] userdiff tests: explicitly test "default" pattern Date: Wed, 24 Feb 2021 20:51:00 +0100 Message-Id: <20210224195129.4004-7-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since 122aa6f9c0 (diff: introduce diff..binary, 2008-10-05) the internals of the userdiff.c code have understood a "default" name, which is invoked as userdiff_find_by_name("default") and present in the "builtin_drivers" struct. Let's test for this special case. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 9675bc17db2..cefe329aea7 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -49,6 +49,7 @@ diffpatterns=" ruby rust tex + default custom1 custom2 custom3 From patchwork Wed Feb 24 19:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102357 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=-15.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,USER_AGENT_GIT 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 DF2A7C433E6 for ; Wed, 24 Feb 2021 19:53:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0D7E64EDD for ; Wed, 24 Feb 2021 19:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235096AbhBXTx2 (ORCPT ); Wed, 24 Feb 2021 14:53:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234706AbhBXTxR (ORCPT ); Wed, 24 Feb 2021 14:53:17 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1CBBC061793 for ; Wed, 24 Feb 2021 11:51:59 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id e10so2824682wro.12 for ; Wed, 24 Feb 2021 11:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8/z8ZiwPZP8JdGwIWJFwe8vn0ba2X8OMmQ7T1QBzD4A=; b=hRFasAwDFYVaEbVcwBFoOOXHh5mNxS0IKE68O7S4/A0eZS3TA1osMeFu2Vo5gcg8FY rnDjPLHRKxbSonjbNdalTFQzD7DZcrQoj6FcdIpC0+BRAQhvz2prcp+cfWvMQ3aGG1Bs qiDz4rvJDdy9FmnbitI2O6nuzbaV3RmywJDaEgtYInq9QKfbubu/O1ZtpGhi/+dQH91E AokJCT5inmY3U5gUiE761Oq0AHMCL1pcLVk8M+4i8t4sYUubpmjxOBxpCVSk41ulh3lR OdAlKA6Sp1REULo/QdsGt4K4CH61uWajzaITo/3gZNKk9Sr9KfhDD5umZqkWgLW+9BcM rPMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8/z8ZiwPZP8JdGwIWJFwe8vn0ba2X8OMmQ7T1QBzD4A=; b=TIaoG0+u7Frk+Gh4uSsxlIOiVDS07JVDUvRtot+whp5gSyi0ckfG/F+IYj3YXq3nja VwMIWbFDuxX+cVRVG9t5okTnO70LQp1J6XDqN/2rHZ7kr7bkA5IsEPYxhZENLndFAuGR U4wSCeIaycf4AuNrt4HuygAvp03cxDmrPVv0h5gcQh92s3Rto6eatOzkwY4YwVZMF7Ao IuzvNj2sjwR5JUHEwG4x/Ni+uCV0BVfKtuGvxKfpkG7Q43paxCA4+jcaGOpdVfxfuj5l DUhqjkOSp8I94SBRhmFnbDYo8lmfL1+ZeHNedE299Rk6tFp6eJ+C3ylBKLUj4WQZJTyU krMw== X-Gm-Message-State: AOAM532YBMzjE0MMBCy2k1vA9eD/YAhbxejD9bqTg4hU4nQLLiG+UsMN EigHDOm5x9awRWhFjfsLSEhjCsPjJMcnjw== X-Google-Smtp-Source: ABdhPJwIP0JHucGBDoQFCL7X5dRsQ++bzSLco30Zf8qLEH2YHB6WrRu68QBDPVzhLTr/+PEyWJjaWQ== X-Received: by 2002:a5d:4d03:: with SMTP id z3mr21037462wrt.211.1614196318409; Wed, 24 Feb 2021 11:51:58 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:51:58 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 07/35] userdiff tests: list builtin drivers via test-tool Date: Wed, 24 Feb 2021 20:51:01 +0100 Message-Id: <20210224195129.4004-8-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the userdiff test to list the builtin drivers via the test-tool, using the new for_each_userdiff_driver() API function. This gets rid of the need to modify this part of the test every time a new pattern is added, see 2ff6c34612 (userdiff: support Bash, 2020-10-22) and 09dad9256a (userdiff: support Markdown, 2020-05-02) for two recent examples. I only need the "list-builtin-drivers "argument here, but let's add "list-custom-drivers" and "list-drivers" too, just because it's easy. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 1 + t/helper/test-tool.c | 1 + t/helper/test-tool.h | 1 + t/helper/test-userdiff.c | 31 +++++++++++++++++++++++++++++++ t/t4018-diff-funcname.sh | 32 ++++++++------------------------ 5 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 t/helper/test-userdiff.c diff --git a/Makefile b/Makefile index 5a239cac20e..710a0deaed0 100644 --- a/Makefile +++ b/Makefile @@ -741,6 +741,7 @@ TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o TEST_BUILTINS_OBJS += test-subprocess.o TEST_BUILTINS_OBJS += test-trace2.o TEST_BUILTINS_OBJS += test-urlmatch-normalization.o +TEST_BUILTINS_OBJS += test-userdiff.o TEST_BUILTINS_OBJS += test-wildmatch.o TEST_BUILTINS_OBJS += test-windows-named-pipe.o TEST_BUILTINS_OBJS += test-write-cache.o diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index f97cd9f48a6..dcb05ca6e5e 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -71,6 +71,7 @@ static struct test_cmd cmds[] = { { "submodule-nested-repo-config", cmd__submodule_nested_repo_config }, { "subprocess", cmd__subprocess }, { "trace2", cmd__trace2 }, + { "userdiff", cmd__userdiff }, { "urlmatch-normalization", cmd__urlmatch_normalization }, { "xml-encode", cmd__xml_encode }, { "wildmatch", cmd__wildmatch }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index 28072c0ad5a..589f2e8ac67 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -61,6 +61,7 @@ int cmd__submodule_config(int argc, const char **argv); int cmd__submodule_nested_repo_config(int argc, const char **argv); int cmd__subprocess(int argc, const char **argv); int cmd__trace2(int argc, const char **argv); +int cmd__userdiff(int argc, const char **argv); int cmd__urlmatch_normalization(int argc, const char **argv); int cmd__xml_encode(int argc, const char **argv); int cmd__wildmatch(int argc, const char **argv); diff --git a/t/helper/test-userdiff.c b/t/helper/test-userdiff.c new file mode 100644 index 00000000000..f173a4f18af --- /dev/null +++ b/t/helper/test-userdiff.c @@ -0,0 +1,31 @@ +#include "test-tool.h" +#include "cache.h" +#include "userdiff.h" + +static int driver_cb(struct userdiff_driver *driver, + enum userdiff_driver_type type, void *priv) +{ + if (driver->funcname.pattern) + puts(driver->name); + return 0; +} + +static int list_what(enum userdiff_driver_type type) +{ + return for_each_userdiff_driver(driver_cb, type, NULL); +} + +int cmd__userdiff(int argc, const char **argv) +{ + if (argc != 2) + return 1; + + if (!strcmp(argv[1], "list-drivers")) + return list_what(USERDIFF_DRIVER_TYPE_UNSPECIFIED); + else if (!strcmp(argv[1], "list-builtin-drivers")) + return list_what(USERDIFF_DRIVER_TYPE_BUILTIN); + else if (!strcmp(argv[1], "list-custom-drivers")) + return list_what(USERDIFF_DRIVER_TYPE_CUSTOM); + else + return error("unknown argument %s", argv[1]); +} diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index cefe329aea7..5bd82e09ab3 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -8,6 +8,13 @@ test_description='Test custom diff function name patterns' . ./test-lib.sh test_expect_success 'setup' ' + # Make sure additions to builtin_drivers are sorted + test_when_finished "rm builtin-drivers.sorted" && + test-tool userdiff list-builtin-drivers >builtin-drivers && + test_file_not_empty builtin-drivers && + sort builtin-drivers.sorted && + test_cmp builtin-drivers.sorted builtin-drivers && + # a non-trivial custom pattern git config diff.custom1.funcname "!static !String @@ -26,30 +33,7 @@ test_expect_success 'setup' ' ' diffpatterns=" - ada - bash - bibtex - cpp - csharp - css - dts - elixir - fortran - fountain - golang - html - java - markdown - matlab - objc - pascal - perl - php - python - ruby - rust - tex - default + $(cat builtin-drivers) custom1 custom2 custom3 From patchwork Wed Feb 24 19:51:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102359 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=-15.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,USER_AGENT_GIT 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 43130C433DB for ; Wed, 24 Feb 2021 19:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0107164EDD for ; Wed, 24 Feb 2021 19:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235136AbhBXTxg (ORCPT ); Wed, 24 Feb 2021 14:53:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234738AbhBXTxS (ORCPT ); Wed, 24 Feb 2021 14:53:18 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1A0CC061794 for ; Wed, 24 Feb 2021 11:52:00 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id o16so2907297wmh.0 for ; Wed, 24 Feb 2021 11:52:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MMD3EnHs+oRiCx+TJvrhvnoiXbDXhjgwygZfIRyT3xk=; b=XOh1v/O2rTgJQ9l7VjFhKUWS2kJ3UgSBb8j8qXN6bhIoJ/frKxYUSJhhCLr32uCdEE SzthB4M3ETKadZRJI+x9qwPy59XPYWTVJfyLPU4fShI0Eb9NOhXk713XBUnYzdAnz4k4 VS8S9bZD0KJWnpwfvVtEBduY8qXMJWsQphVaQ8N2XTm8JgNAgVjNWxMpBRcF67dGj1ol fjDbr2oEmDzWCxoIRSNE0ny4XJvaYI6WA4jDW/YjsXOLXRQn0LASixqAN4Hb0wDqW8po GPGvAM3xpUw29604oBmevRhU8cmu50ttsA/SaCVqvpeQcHzWK/J+hhOaFSXmhg2d6J79 Cquw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MMD3EnHs+oRiCx+TJvrhvnoiXbDXhjgwygZfIRyT3xk=; b=La7dcgFSE/+qaTMEURJ1JYB2r7OZbp1aUnYKlztEliNuKXY+OwMYF+iUTHl6PUf7GC ljsQvLza26ZBb0sAk4RJ1cSUDtXpjaEZuUupFYXxdwBCYwsOgso2qD7LIG5JsBiHgBUI 9egqmDBVVDQHXJTkh7MV+lKt59cHThzpNKN21lFbQZXuzjXAvM6Zxq1t/X4vVFxBDsCl ezi4fqP5a88r4J+lneuqrAAcD41CtpTTObI0P2YLk2/CW/+pwu5Uz0OKIt9+nMfnWqbD vsW78GP7JUEhbDCZSQHIn5VAF74pNsHHn3A7Nz8jfoFZkNp8a728Xks+ch94XovYvvJ0 aFzA== X-Gm-Message-State: AOAM531l1TRGWRCgViX6xK3y9EcgAErHpcxPx7mzmWyavD0aujnAu+uw 5gbf74AjWjtVdkfVdrB3t7Yq1VLXaNdQHw== X-Google-Smtp-Source: ABdhPJzxkN+SNOluiDU3qtENvq4HBxLOUqJ2DuY2XCXMWhzB6JuVEZUzEDz6rwN8OTKMoX5tBL4bgQ== X-Received: by 2002:a1c:7c17:: with SMTP id x23mr5207964wmc.95.1614196319327; Wed, 24 Feb 2021 11:51:59 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:51:58 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 08/35] userdiff: remove support for "broken" tests Date: Wed, 24 Feb 2021 20:51:02 +0100 Message-Id: <20210224195129.4004-9-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There have been no "broken" tests since 75c3b6b2e8 (userdiff: improve Fortran xfuncname regex, 2020-08-12). Let's remove the test support for them, this is in preparation for a more general refactoring of the tests. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 8 +------- t/t4018/README | 3 --- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 5bd82e09ab3..9aec9f8e6de 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -86,13 +86,7 @@ test_expect_success 'setup hunk header tests' ' # check each individual file for i in $(git ls-files) do - if grep broken "$i" >/dev/null 2>&1 - then - result=failure - else - result=success - fi - test_expect_$result "hunk header: $i" " + test_expect_success "hunk header: $i" " git diff -U1 $i >actual && grep '@@ .* @@.*RIGHT' actual " diff --git a/t/t4018/README b/t/t4018/README index 283e01cca1a..2d25b2b4fc9 100644 --- a/t/t4018/README +++ b/t/t4018/README @@ -7,9 +7,6 @@ at least two lines from the line that must appear in the hunk header. The text that must appear in the hunk header must contain the word "right", but in all upper-case, like in the title above. -To mark a test case that highlights a malfunction, insert the word -BROKEN in all lower-case somewhere in the file. - This text is a bit twisted and out of order, but it is itself a test case for the default hunk header pattern. Know what you are doing if you change it. From patchwork Wed Feb 24 19:51:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102361 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=-15.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,USER_AGENT_GIT 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 5EA70C433E0 for ; Wed, 24 Feb 2021 19:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2330664F03 for ; Wed, 24 Feb 2021 19:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233615AbhBXTxv (ORCPT ); Wed, 24 Feb 2021 14:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234751AbhBXTxS (ORCPT ); Wed, 24 Feb 2021 14:53:18 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95B9CC061797 for ; Wed, 24 Feb 2021 11:52:01 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id r3so3028542wro.9 for ; Wed, 24 Feb 2021 11:52:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SXtGFsgRGxvA9gGTTtAzLV/ceeBxBqYANef/qRpivO8=; b=cLPVh9k+RzdiYTpcBXhDMUXOovBWH67UY40wMRdrjNxb70siJUz+awzoWnN4Zos/ki Clx/CHmRDltGXfHCpFLbMkN5S4H1Dh6TMlC0IS8w4usk9U9ptTDwno3KSSVy6/cfzMIs +JrYdrBZtKSh3samgs1D7Nc10U4BJcBIjyftO7pMDSOwiYkl3eHslO6x3xZ43GQMc+D5 LKFPIMjgF/VXMNowtaD1AOEL/fKsTI7sJze8oFHv+BEVfKPimZEnbfx5xRW33a0vFGEG 2kRk+1et4LrF3rYIbVHIylOov5asZgHLJ4rkVjB1srUjnAfFEvcIVvUGaadwi+dxn2+D 9SBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SXtGFsgRGxvA9gGTTtAzLV/ceeBxBqYANef/qRpivO8=; b=C/T9+gqiJ6Oi6DeTfDDt4UiFNPHWTNjQp9pCc2tqG91KCr1llFT38CQrF+42QaqyE/ syT0+ZPed5Gf60R03V5lSRrcnC+3DgQWJFKBP3yXShk+RITwSMqQyqNH4pBk88j+nA4g Ij17YRvMdpz+vTLYbwn5MMLt5eqeujqeAB9qKrlhJcxVwqoeY77FueEsN/O2blrjw5pR jq9m1s7WDjNO3JNKKRG/UE0xW8zyW2YzQGSeHQHJBdYtRhLApu7iqisVuIeDNO2xJyBQ Mjtp6YvKLK6jYMmcgOZsMkfDvba6F3DSKKFRyBHQpdvBUnN8FJw/3GCrIt8N1+f4PVqE VPCQ== X-Gm-Message-State: AOAM532IRdB+TTtfJs/AlzQqRhz+cybz3SSkb9usfY1rtj5uruYu1gmr inPkaRFrduEgf8sOecyrrI2eOEyP+FDXbQ== X-Google-Smtp-Source: ABdhPJxx7fbXgAc+yWweROPtaCTl8+Hhp6JcNCZCDFN9A0tW6AFpLy+cNxlrpQK+bkrAWQbaHb6X6A== X-Received: by 2002:adf:a2d3:: with SMTP id t19mr26148052wra.299.1614196320144; Wed, 24 Feb 2021 11:52:00 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:51:59 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 09/35] blame tests: don't rely on t/t4018/ directory Date: Wed, 24 Feb 2021 20:51:03 +0100 Message-Id: <20210224195129.4004-10-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor a test added in 9466e3809d (blame: enable funcname blaming with userdiff driver, 2020-11-01) so that the blame tests don't rely on stealing the contents of "t/t4018/fortran-external-function". I'm about to change that file in a subsequent commit. Just moving the relevant test file here inline is the easiest solution, and I think also the most readable. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/annotate-tests.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 29ce89090d8..04a2c58594c 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -482,12 +482,22 @@ test_expect_success 'blame -L ^:RE (absolute: end-of-file)' ' test_expect_success 'setup -L :funcname with userdiff driver' ' echo "fortran-* diff=fortran" >.gitattributes && fortran_file=fortran-external-function && - orig_file="$TEST_DIRECTORY/t4018/$fortran_file" && - cp "$orig_file" . && + cat >$fortran_file <<-\EOF && + function RIGHT(a, b) result(c) + + integer, intent(in) :: ChangeMe + integer, intent(in) :: b + integer, intent(out) :: c + + c = a+b + + end function RIGHT + EOF git add "$fortran_file" && GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="A@test.git" \ git commit -m "add fortran file" && - sed -e "s/ChangeMe/IWasChanged/" <"$orig_file" >"$fortran_file" && + sed -e "s/ChangeMe/IWasChanged/" <"$fortran_file" >"$fortran_file".tmp && + mv "$fortran_file".tmp "$fortran_file" && git add "$fortran_file" && GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="B@test.git" \ git commit -m "change fortran file" From patchwork Wed Feb 24 19:51:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102363 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=-15.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,USER_AGENT_GIT 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 8E603C433E6 for ; Wed, 24 Feb 2021 19:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4396564F07 for ; Wed, 24 Feb 2021 19:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234496AbhBXTx4 (ORCPT ); Wed, 24 Feb 2021 14:53:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234761AbhBXTxS (ORCPT ); Wed, 24 Feb 2021 14:53:18 -0500 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 731A2C0617A7 for ; Wed, 24 Feb 2021 11:52:02 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id v1so3037046wrd.6 for ; Wed, 24 Feb 2021 11:52:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YOfhct70mj0/lRM5+pXeLT20kW9w8bK9KR3a20Tq3vc=; b=L6waIUu5LRNsF9mv8LFQXIXbZ3j8dgJmGatdDOYPJeKOxWkKNDuN9WOC0vA26jN5Eu 4Msuy5n0+/QWuIOcQPsX7tntUFJC3R/SxstKNqOPvgLAxOt2Xyn6QNstUD20G6qM8pNP 8mVG+npzwV5vZX69OG3ZZzxkEiZV1cDjMyYTuPbcxCwJrrGrxT0dwZ+5kMbLeQMv5Nxj x5VtuA8FFQPcOkfR+4Y7hiFh+pibreSI8tV0ywi1MRYn3iqK2tZhNYO1OFuJ3od10n+z 6X5MH2tWxhK0qa8sWAXCVpA8/uAaCM20n2/WzH0PHTmT55+c5IqUI1O6K1ahTWPNVk97 CphQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YOfhct70mj0/lRM5+pXeLT20kW9w8bK9KR3a20Tq3vc=; b=EiY8tcC2he+BnsScdDbULA1kSK4jewWklO8A0aTcjJKUIFQjJl2jBMCLLO2VgmAPfN hy3bFG+PIaoBC54s3OgGqkA+Bk8tqtyaVAh0ijijwe7ZzPFLdgIbMx9qAbW06OKzUXEy Oo/UGWAaPBVfyAGIbSuRTmgrhpW6pPxwfHNkZoPI7njV5xl5nLcpuikLAu9bTxiFBwNv woKa47heLG9aeoBVoPQ7bVm4PUYfI2EnnenmCJwA/EKvm3fWAybOvvn56tXBDCe8z2wL 7gf7wJ+Yhn9C+IrOYW4OMnK0qcZAks7nYvGecxoQTZRn8kSFyRRFakx3chGZ1L1CrNAF A1/w== X-Gm-Message-State: AOAM531hBrUNfq5cRaiy/Gs9YO/0s4yzKukMaPHin+Br2YfUz37crzN8 AdbZRwV2990fkAwS+kGoy7Oc3yw6v8tHDw== X-Google-Smtp-Source: ABdhPJwA01WzQA3fdxlc4ACJn1q5xgmzkN2WMNV6MEmn/pSKwbR1cKOVPoymbWovoSqxBXVYFF0ugg== X-Received: by 2002:a05:6000:1101:: with SMTP id z1mr33844626wrw.110.1614196320943; Wed, 24 Feb 2021 11:52:00 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:00 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 10/35] blame tests: simplify userdiff driver test Date: Wed, 24 Feb 2021 20:51:04 +0100 Message-Id: <20210224195129.4004-11-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Simplify the test added in 9466e3809d (blame: enable funcname blaming with userdiff driver, 2020-11-01) to use the --author support recently added in 999cfc4f45 (test-lib functions: add --author support to test_commit, 2021-01-12). We also did not need the full fortran-external-function content. Let's cut it down to just the important parts, and further modify it to demonstrate that the fortran-specific userdiff function is in effect by adding "DO NOT MATCH ..." and "AS THE ..." lines surrounding the "RIGHT" one. This is to check that we're using the userdiff "fortran" driver, as opposed to the default driver. The test also left behind a .gitattributes files, let's clean it up with "test_when_finished". Signed-off-by: Ævar Arnfjörð Bjarmason --- t/annotate-tests.sh | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 04a2c58594c..d3b299e75cb 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -479,32 +479,26 @@ test_expect_success 'blame -L ^:RE (absolute: end-of-file)' ' check_count -f hello.c -L$n -L^:ma.. F 4 G 1 H 1 ' -test_expect_success 'setup -L :funcname with userdiff driver' ' - echo "fortran-* diff=fortran" >.gitattributes && - fortran_file=fortran-external-function && - cat >$fortran_file <<-\EOF && +test_expect_success 'blame -L :funcname with userdiff driver' ' + cat >file.template <<-\EOF && + DO NOT MATCH THIS LINE function RIGHT(a, b) result(c) + AS THE DEFAULT DRIVER WOULD integer, intent(in) :: ChangeMe - integer, intent(in) :: b - integer, intent(out) :: c - - c = a+b - - end function RIGHT EOF - git add "$fortran_file" && - GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="A@test.git" \ - git commit -m "add fortran file" && - sed -e "s/ChangeMe/IWasChanged/" <"$fortran_file" >"$fortran_file".tmp && - mv "$fortran_file".tmp "$fortran_file" && - git add "$fortran_file" && - GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="B@test.git" \ - git commit -m "change fortran file" -' -test_expect_success 'blame -L :funcname with userdiff driver' ' - check_count -f fortran-external-function -L:RIGHT A 7 B 1 + fortran_file=file.f03 && + test_when_finished "rm .gitattributes" && + echo "$fortran_file diff=fortran" >.gitattributes && + + test_commit --author "A " \ + "add" "$fortran_file" \ + "$(cat file.template)" && + test_commit --author "B " \ + "change" "$fortran_file" \ + "$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" && + check_count -f "$fortran_file" -L:RIGHT A 3 B 1 ' test_expect_success 'setup incremental' ' From patchwork Wed Feb 24 19:51:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102371 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=-15.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,USER_AGENT_GIT 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 E71BAC433E0 for ; Wed, 24 Feb 2021 19:54:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75FD964EDD for ; Wed, 24 Feb 2021 19:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235269AbhBXTyU (ORCPT ); Wed, 24 Feb 2021 14:54:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234883AbhBXTxV (ORCPT ); Wed, 24 Feb 2021 14:53:21 -0500 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 213D4C0617AA for ; Wed, 24 Feb 2021 11:52:04 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id t15so3022328wrx.13 for ; Wed, 24 Feb 2021 11:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=144Eodcd+A9WrB2tmeZVO93cvJvYYmqQn5GkjRq1+a8=; b=enNd6E6org3bwhQy/I/oxH24icx46laFz7nEgtQNcH4H8Aw3o6kNGmJT7gLseD0vuy n/F8hrRHgx8blRB948jv5CU2sPf/0aeFfnN2/8BfC7EglP6TgXx/npXcz3OoXryINmU0 LTM0HRTD45NpodjNQC/g3H5tpSiiC9UZLC9yLhhT+eoKbCXTCUhQQd0sNAQllJg8v8gR YI/bDVZPH5/DjI3zzodp9tM3ttdfi/Q6M5bFoVzv8g899siof7L6X5cvzDQ3SJJvKYXa +pDBTW/za0nDKAM3s5wELxG5M7C1IAx3i5wdSisb/NIMJtRXMAyqnL3WY+ifn2/7Fazy YAcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=144Eodcd+A9WrB2tmeZVO93cvJvYYmqQn5GkjRq1+a8=; b=Ym9wM/7TPF9DxtHgnrlLJPDStrKQqb1rlrnBZJDsCky+dXLPCQIx3Na+tlgUk9CZcA LiCcvwwkyVT89nCaA8PH0Y9c5RrnPw6IyzUcBTYmNSrqkjqbJhpOPhfhW0T+cAgbVc/r l6ynlK4Kmze25n/iWVM2THuKW8BxpN7ws8dZzNLnludwxEMoyVLYMMuBk8gSXU49UoCm oRXUQlO1Pe7g9psuBZavqGa8Gw2xkgQtUhYHFk0m5icZJ9awqLmSy98O/6Qo7+IoD4/Y NUKC23u7oghdMjgezN2VntIHHPQBTvgRxUeQzJEMpeNHY9PoyTXb+b/wbG+2WMAi75BB PPhg== X-Gm-Message-State: AOAM532SRqV7o7P6qGeOdREJA7K+lpVoX52vwU4I7Tr1SUa2FpEMdvv3 RKYAmjM9cEE4MIsW428fMaO6k4or8XlodA== X-Google-Smtp-Source: ABdhPJzAcFTj88Gn2MzrcZMpaCtc+QWMEQULVnbRtEhsMaFOY5MU00338Rol5RhVDtWyklVEjIgIsg== X-Received: by 2002:a5d:6706:: with SMTP id o6mr25784584wru.235.1614196321699; Wed, 24 Feb 2021 11:52:01 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:01 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 11/35] userdiff tests: match full hunk headers Date: Wed, 24 Feb 2021 20:51:05 +0100 Message-Id: <20210224195129.4004-12-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a regression in the test framework for userdiff added in bfa7d01413 (t4018: an infrastructure to test hunk headers, 2014-03-21). The testing infrastructure added in that change went overboard with simplifying the tests, to the point where we lost test coverage. Before that we'd been able to test the full context line, or ever since the feature was originally added in f258475a6e (Per-path attribute based hunk header selection., 2007-07-06). After bfa7d01413 all we cared about was whether "RIGHT" appeared on the line. We thus lost the information about whether or not "RIGHT" was extracted from the line for the hunk header, or the line appeared in full (or other subset of the line). Let's bring back coverage for that by extending the custom test syntax here to understand "t4018" control lines, we grep those out before doing the add/diff, and understand "t4018 header: " lines to declare the full context line we're expecting. Now when we have failures we'll benefit from the full test_cmp output, instead of just getting a non-zero exit code from "grep". The "sed -n -e" here was originally a single 's/^.*@@\( \|$\)//p' pattern, but the '\( \|$\)' part had portability issues on OSX and AIX. The one-off addition of headers here to the test files was done by instrumenting the test itself: grep '@@ .* @@.*RIGHT' actual >header.right && sed 's/^@@.*@@ //' header.right >$i.header.small && mv \"$TEST_DIRECTORY\"/t4018/$i tmp && printf 't4018 header: ' >\"$TEST_DIRECTORY\"/t4018/$i && cat $i.header.small >> \"$TEST_DIRECTORY\"/t4018/$i && cat tmp >>\"$TEST_DIRECTORY\"/t4018/$i Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 27 +++++++++++++--------- t/t4018/README | 25 ++++++++++++-------- t/t4018/bash-arithmetic-function | 1 + t/t4018/bash-bashism-style-compact | 1 + t/t4018/bash-bashism-style-function | 1 + t/t4018/bash-bashism-style-whitespace | 1 + t/t4018/bash-conditional-function | 1 + t/t4018/bash-missing-parentheses | 1 + t/t4018/bash-mixed-style-compact | 1 + t/t4018/bash-mixed-style-function | 1 + t/t4018/bash-nested-functions | 1 + t/t4018/bash-other-characters | 1 + t/t4018/bash-posix-style-compact | 1 + t/t4018/bash-posix-style-function | 1 + t/t4018/bash-posix-style-whitespace | 1 + t/t4018/bash-subshell-function | 1 + t/t4018/bash-trailing-comment | 1 + t/t4018/cpp-c++-function | 1 + t/t4018/cpp-class-constructor | 1 + t/t4018/cpp-class-constructor-mem-init | 1 + t/t4018/cpp-class-definition | 1 + t/t4018/cpp-class-definition-derived | 1 + t/t4018/cpp-class-destructor | 1 + t/t4018/cpp-function-returning-global-type | 1 + t/t4018/cpp-function-returning-nested | 1 + t/t4018/cpp-function-returning-pointer | 1 + t/t4018/cpp-function-returning-reference | 1 + t/t4018/cpp-gnu-style-function | 1 + t/t4018/cpp-namespace-definition | 1 + t/t4018/cpp-operator-definition | 1 + t/t4018/cpp-skip-access-specifiers | 1 + t/t4018/cpp-skip-comment-block | 1 + t/t4018/cpp-skip-labels | 1 + t/t4018/cpp-struct-definition | 1 + t/t4018/cpp-struct-single-line | 1 + t/t4018/cpp-template-function-definition | 1 + t/t4018/cpp-union-definition | 1 + t/t4018/cpp-void-c-function | 1 + t/t4018/css-attribute-value-selector | 1 + t/t4018/css-block-level-@-statements | 1 + t/t4018/css-brace-in-col-1 | 1 + t/t4018/css-class-selector | 1 + t/t4018/css-colon-eol | 1 + t/t4018/css-colon-selector | 1 + t/t4018/css-common | 1 + t/t4018/css-id-selector | 1 + t/t4018/css-long-selector-list | 1 + t/t4018/css-prop-sans-indent | 1 + t/t4018/css-root-selector | 1 + t/t4018/css-short-selector-list | 1 + t/t4018/css-trailing-space | 1 + t/t4018/custom1-pattern | 1 + t/t4018/custom2-match-to-end-of-line | 1 + t/t4018/custom3-alternation-in-pattern | 1 + t/t4018/dts-labels | 1 + t/t4018/dts-node-unitless | 1 + t/t4018/dts-nodes | 1 + t/t4018/dts-nodes-boolean-prop | 1 + t/t4018/dts-nodes-comment1 | 1 + t/t4018/dts-nodes-comment2 | 1 + t/t4018/dts-nodes-multiline-prop | 1 + t/t4018/dts-reference | 1 + t/t4018/dts-root | 1 + t/t4018/dts-root-comment | 1 + t/t4018/elixir-do-not-pick-end | 1 + t/t4018/elixir-ex-unit-test | 1 + t/t4018/elixir-function | 1 + t/t4018/elixir-macro | 1 + t/t4018/elixir-module | 1 + t/t4018/elixir-module-func | 1 + t/t4018/elixir-nested-module | 1 + t/t4018/elixir-private-function | 1 + t/t4018/elixir-protocol | 1 + t/t4018/elixir-protocol-implementation | 1 + t/t4018/fortran-block-data | 1 + t/t4018/fortran-comment | 1 + t/t4018/fortran-comment-keyword | 1 + t/t4018/fortran-comment-legacy | 1 + t/t4018/fortran-comment-legacy-star | 1 + t/t4018/fortran-external-function | 1 + t/t4018/fortran-external-subroutine | 1 + t/t4018/fortran-module | 1 + t/t4018/fortran-module-procedure | 1 + t/t4018/fortran-program | 1 + t/t4018/fountain-scene | 1 + t/t4018/golang-complex-function | 1 + t/t4018/golang-func | 1 + t/t4018/golang-interface | 1 + t/t4018/golang-long-func | 1 + t/t4018/golang-struct | 1 + t/t4018/java-class-member-function | 1 + t/t4018/markdown-heading-indented | 1 + t/t4018/markdown-heading-non-headings | 1 + t/t4018/matlab-class-definition | 1 + t/t4018/matlab-function | 1 + t/t4018/matlab-octave-section-1 | 1 + t/t4018/matlab-octave-section-2 | 1 + t/t4018/matlab-section | 1 + t/t4018/perl-skip-end-of-heredoc | 1 + t/t4018/perl-skip-forward-decl | 1 + t/t4018/perl-skip-sub-in-pod | 1 + t/t4018/perl-sub-definition | 1 + t/t4018/perl-sub-definition-kr-brace | 1 + t/t4018/php-abstract-class | 1 + t/t4018/php-abstract-method | 1 + t/t4018/php-class | 1 + t/t4018/php-final-class | 1 + t/t4018/php-final-method | 1 + t/t4018/php-function | 1 + t/t4018/php-interface | 1 + t/t4018/php-method | 1 + t/t4018/php-trait | 1 + t/t4018/python-async-def | 1 + t/t4018/python-class | 1 + t/t4018/python-def | 1 + t/t4018/python-indented-async-def | 1 + t/t4018/python-indented-class | 1 + t/t4018/python-indented-def | 1 + t/t4018/rust-fn | 1 + t/t4018/rust-impl | 1 + t/t4018/rust-macro-rules | 1 + t/t4018/rust-struct | 1 + t/t4018/rust-trait | 1 + 123 files changed, 153 insertions(+), 20 deletions(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 9aec9f8e6de..15dcbe735ca 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -70,16 +70,20 @@ test_expect_success 'setup hunk header tests' ' echo "$i-* diff=$i" done > .gitattributes && - # add all test files to the index - ( - cd "$TEST_DIRECTORY"/t4018 && - git --git-dir="$TRASH_DIRECTORY/.git" add . - ) && - - # place modified files in the worktree - for i in $(git ls-files) + cp -R "$TEST_DIRECTORY"/t4018 . && + git init t4018 && + git -C t4018 add . && + + for i in $(git -C t4018 ls-files) do - sed -e "s/ChangeMe/IWasChanged/" <"$TEST_DIRECTORY/t4018/$i" >"$i" || return 1 + grep -v "^t4018" "t4018/$i" >"t4018/$i.content" && + sed -n -e "s/^t4018 header: //p" <"t4018/$i" >"t4018/$i.header" && + cp "t4018/$i.content" "$i" && + + # add test file to the index + git add "$i" && + # place modified file in the worktree + sed -e "s/ChangeMe/IWasChanged/" <"t4018/$i.content" >"$i" || return 1 done ' @@ -87,8 +91,9 @@ test_expect_success 'setup hunk header tests' ' for i in $(git ls-files) do test_expect_success "hunk header: $i" " - git diff -U1 $i >actual && - grep '@@ .* @@.*RIGHT' actual + git diff -U1 $i >diff && + sed -n -e 's/^.*@@$//p' -e 's/^.*@@ //p' ctx && + test_cmp t4018/$i.header ctx " done diff --git a/t/t4018/README b/t/t4018/README index 2d25b2b4fc9..0a246bbc10e 100644 --- a/t/t4018/README +++ b/t/t4018/README @@ -1,15 +1,22 @@ -How to write RIGHT test cases -============================= +t4018 header: description of the test. +How to write test cases +======================= + +Create test cases called "LANG-whatever" in this directory, where +"LANG" is e.g. the userdiff driver name, where "whatever" is a brief +description of the test. Insert the word "ChangeMe" (exactly this form) at a distance of at least two lines from the line that must appear in the hunk header. -The text that must appear in the hunk header must contain the word -"right", but in all upper-case, like in the title above. +Any line starting with "t4018" is a control line for the test: -This text is a bit twisted and out of order, but it is itself a -test case for the default hunk header pattern. Know what you are doing -if you change it. + - The "t4018 header:" line above specifies what text must appear in + the hunk header. We strip away the starting "@@ [...] @@" part of + the line for ease of not having to hardcode the line numbers and + offsets. -BTW, this tests that the head line goes to the hunk header, not the line -of equal signs. +In many of the test cases the header line includes the token "RIGHT", +this used to be part of the test syntax, but isn't anymore. Now we +care about the "t4018 header:" line, not whatever line contains a +"RIGHT" token. diff --git a/t/t4018/bash-arithmetic-function b/t/t4018/bash-arithmetic-function index c0b276cb50f..f5609bf49eb 100644 --- a/t/t4018/bash-arithmetic-function +++ b/t/t4018/bash-arithmetic-function @@ -1,3 +1,4 @@ +t4018 header: RIGHT() RIGHT() (( ChangeMe = "$x" + "$y" diff --git a/t/t4018/bash-bashism-style-compact b/t/t4018/bash-bashism-style-compact index 1ca3126f611..42611aad166 100644 --- a/t/t4018/bash-bashism-style-compact +++ b/t/t4018/bash-bashism-style-compact @@ -1,3 +1,4 @@ +t4018 header: function RIGHT { function RIGHT { function InvalidSyntax{ : diff --git a/t/t4018/bash-bashism-style-function b/t/t4018/bash-bashism-style-function index f1de4fa831c..823b13a463b 100644 --- a/t/t4018/bash-bashism-style-function +++ b/t/t4018/bash-bashism-style-function @@ -1,3 +1,4 @@ +t4018 header: function RIGHT { function RIGHT { : echo 'ChangeMe' diff --git a/t/t4018/bash-bashism-style-whitespace b/t/t4018/bash-bashism-style-whitespace index ade85dd3a50..4f1add4a4e5 100644 --- a/t/t4018/bash-bashism-style-whitespace +++ b/t/t4018/bash-bashism-style-whitespace @@ -1,3 +1,4 @@ +t4018 header: function RIGHT ( ) { function RIGHT ( ) { ChangeMe diff --git a/t/t4018/bash-conditional-function b/t/t4018/bash-conditional-function index c5949e829ba..1e71a71a320 100644 --- a/t/t4018/bash-conditional-function +++ b/t/t4018/bash-conditional-function @@ -1,3 +1,4 @@ +t4018 header: RIGHT() RIGHT() [[ \ "$a" > "$ChangeMe" diff --git a/t/t4018/bash-missing-parentheses b/t/t4018/bash-missing-parentheses index 8c8a05dd7ab..9233042d91f 100644 --- a/t/t4018/bash-missing-parentheses +++ b/t/t4018/bash-missing-parentheses @@ -1,3 +1,4 @@ +t4018 header: function RIGHT { function RIGHT { functionInvalidSyntax { : diff --git a/t/t4018/bash-mixed-style-compact b/t/t4018/bash-mixed-style-compact index d9364cba671..0f93c2be55a 100644 --- a/t/t4018/bash-mixed-style-compact +++ b/t/t4018/bash-mixed-style-compact @@ -1,3 +1,4 @@ +t4018 header: function RIGHT(){ function RIGHT(){ : echo 'ChangeMe' diff --git a/t/t4018/bash-mixed-style-function b/t/t4018/bash-mixed-style-function index 555f9b24667..b3024cdc6dc 100644 --- a/t/t4018/bash-mixed-style-function +++ b/t/t4018/bash-mixed-style-function @@ -1,3 +1,4 @@ +t4018 header: function RIGHT() { function RIGHT() { ChangeMe diff --git a/t/t4018/bash-nested-functions b/t/t4018/bash-nested-functions index 2c9237ead42..1eee6b9a830 100644 --- a/t/t4018/bash-nested-functions +++ b/t/t4018/bash-nested-functions @@ -1,3 +1,4 @@ +t4018 header: RIGHT() outer() { RIGHT() { : diff --git a/t/t4018/bash-other-characters b/t/t4018/bash-other-characters index a3f390d525d..02fa1ec822d 100644 --- a/t/t4018/bash-other-characters +++ b/t/t4018/bash-other-characters @@ -1,3 +1,4 @@ +t4018 header: _RIGHT_0n() _RIGHT_0n() { ChangeMe diff --git a/t/t4018/bash-posix-style-compact b/t/t4018/bash-posix-style-compact index 045bd2029b7..7ba61dea663 100644 --- a/t/t4018/bash-posix-style-compact +++ b/t/t4018/bash-posix-style-compact @@ -1,3 +1,4 @@ +t4018 header: RIGHT() RIGHT(){ ChangeMe diff --git a/t/t4018/bash-posix-style-function b/t/t4018/bash-posix-style-function index a4d144856e9..8566c3f3838 100644 --- a/t/t4018/bash-posix-style-function +++ b/t/t4018/bash-posix-style-function @@ -1,3 +1,4 @@ +t4018 header: RIGHT() RIGHT() { ChangeMe diff --git a/t/t4018/bash-posix-style-whitespace b/t/t4018/bash-posix-style-whitespace index 4d984f0aa4d..dcc06da3f67 100644 --- a/t/t4018/bash-posix-style-whitespace +++ b/t/t4018/bash-posix-style-whitespace @@ -1,3 +1,4 @@ +t4018 header: RIGHT ( ) RIGHT ( ) { ChangeMe diff --git a/t/t4018/bash-subshell-function b/t/t4018/bash-subshell-function index 80baa09484e..f6b188679a2 100644 --- a/t/t4018/bash-subshell-function +++ b/t/t4018/bash-subshell-function @@ -1,3 +1,4 @@ +t4018 header: RIGHT() RIGHT() ( ChangeMe=2 diff --git a/t/t4018/bash-trailing-comment b/t/t4018/bash-trailing-comment index f1edbeda319..16ba9701f3f 100644 --- a/t/t4018/bash-trailing-comment +++ b/t/t4018/bash-trailing-comment @@ -1,3 +1,4 @@ +t4018 header: RIGHT() RIGHT() { # Comment ChangeMe diff --git a/t/t4018/cpp-c++-function b/t/t4018/cpp-c++-function index 9ee6bbef557..316ad0eb34f 100644 --- a/t/t4018/cpp-c++-function +++ b/t/t4018/cpp-c++-function @@ -1,3 +1,4 @@ +t4018 header: Item RIGHT::DoSomething( Args with_spaces ) Item RIGHT::DoSomething( Args with_spaces ) { ChangeMe; diff --git a/t/t4018/cpp-class-constructor b/t/t4018/cpp-class-constructor index ec4f115c250..38552023f00 100644 --- a/t/t4018/cpp-class-constructor +++ b/t/t4018/cpp-class-constructor @@ -1,3 +1,4 @@ +t4018 header: Item::Item(int RIGHT) Item::Item(int RIGHT) { ChangeMe; diff --git a/t/t4018/cpp-class-constructor-mem-init b/t/t4018/cpp-class-constructor-mem-init index 49a69f37e16..dc48c12ac25 100644 --- a/t/t4018/cpp-class-constructor-mem-init +++ b/t/t4018/cpp-class-constructor-mem-init @@ -1,3 +1,4 @@ +t4018 header: Item::Item(int RIGHT) : Item::Item(int RIGHT) : member(0) { diff --git a/t/t4018/cpp-class-definition b/t/t4018/cpp-class-definition index 11b61da3b75..1f258c8f980 100644 --- a/t/t4018/cpp-class-definition +++ b/t/t4018/cpp-class-definition @@ -1,3 +1,4 @@ +t4018 header: class RIGHT class RIGHT { int ChangeMe; diff --git a/t/t4018/cpp-class-definition-derived b/t/t4018/cpp-class-definition-derived index 3b98cd09ab5..1e5ec3b4837 100644 --- a/t/t4018/cpp-class-definition-derived +++ b/t/t4018/cpp-class-definition-derived @@ -1,3 +1,4 @@ +t4018 header: class RIGHT : class RIGHT : public Baseclass { diff --git a/t/t4018/cpp-class-destructor b/t/t4018/cpp-class-destructor index 54876650965..a06a37169ad 100644 --- a/t/t4018/cpp-class-destructor +++ b/t/t4018/cpp-class-destructor @@ -1,3 +1,4 @@ +t4018 header: RIGHT::~RIGHT() RIGHT::~RIGHT() { ChangeMe; diff --git a/t/t4018/cpp-function-returning-global-type b/t/t4018/cpp-function-returning-global-type index 1084d5990ef..9bb8f57474f 100644 --- a/t/t4018/cpp-function-returning-global-type +++ b/t/t4018/cpp-function-returning-global-type @@ -1,3 +1,4 @@ +t4018 header: ::Item get::it::RIGHT() ::Item get::it::RIGHT() { ChangeMe; diff --git a/t/t4018/cpp-function-returning-nested b/t/t4018/cpp-function-returning-nested index d9750aa61a5..3a35a39816a 100644 --- a/t/t4018/cpp-function-returning-nested +++ b/t/t4018/cpp-function-returning-nested @@ -1,3 +1,4 @@ +t4018 header: get::Item get::it::RIGHT() get::Item get::it::RIGHT() { ChangeMe; diff --git a/t/t4018/cpp-function-returning-pointer b/t/t4018/cpp-function-returning-pointer index ef15657ea8f..9890c5488db 100644 --- a/t/t4018/cpp-function-returning-pointer +++ b/t/t4018/cpp-function-returning-pointer @@ -1,3 +1,4 @@ +t4018 header: const char *get_it_RIGHT(char *ptr) const char *get_it_RIGHT(char *ptr) { ChangeMe; diff --git a/t/t4018/cpp-function-returning-reference b/t/t4018/cpp-function-returning-reference index 01b051df701..7147ab9a74d 100644 --- a/t/t4018/cpp-function-returning-reference +++ b/t/t4018/cpp-function-returning-reference @@ -1,3 +1,4 @@ +t4018 header: string& get::it::RIGHT(char *ptr) string& get::it::RIGHT(char *ptr) { ChangeMe; diff --git a/t/t4018/cpp-gnu-style-function b/t/t4018/cpp-gnu-style-function index 08c7c7565ae..91e243f3869 100644 --- a/t/t4018/cpp-gnu-style-function +++ b/t/t4018/cpp-gnu-style-function @@ -1,3 +1,4 @@ +t4018 header: RIGHT(int arg) const char * RIGHT(int arg) { diff --git a/t/t4018/cpp-namespace-definition b/t/t4018/cpp-namespace-definition index 6749980241c..bd32988b3f9 100644 --- a/t/t4018/cpp-namespace-definition +++ b/t/t4018/cpp-namespace-definition @@ -1,3 +1,4 @@ +t4018 header: namespace RIGHT namespace RIGHT { ChangeMe; diff --git a/t/t4018/cpp-operator-definition b/t/t4018/cpp-operator-definition index 1acd8271592..7e8ba945281 100644 --- a/t/t4018/cpp-operator-definition +++ b/t/t4018/cpp-operator-definition @@ -1,3 +1,4 @@ +t4018 header: Value operator+(Value LEFT, Value RIGHT) Value operator+(Value LEFT, Value RIGHT) { ChangeMe; diff --git a/t/t4018/cpp-skip-access-specifiers b/t/t4018/cpp-skip-access-specifiers index 4d4a9dbb9db..d61c86d3703 100644 --- a/t/t4018/cpp-skip-access-specifiers +++ b/t/t4018/cpp-skip-access-specifiers @@ -1,3 +1,4 @@ +t4018 header: class RIGHT : public Baseclass class RIGHT : public Baseclass { public: diff --git a/t/t4018/cpp-skip-comment-block b/t/t4018/cpp-skip-comment-block index 3800b9967a5..ea4d9c25911 100644 --- a/t/t4018/cpp-skip-comment-block +++ b/t/t4018/cpp-skip-comment-block @@ -1,3 +1,4 @@ +t4018 header: struct item RIGHT(int i) struct item RIGHT(int i) // Do not // pick up diff --git a/t/t4018/cpp-skip-labels b/t/t4018/cpp-skip-labels index b9c10aba225..cf508647281 100644 --- a/t/t4018/cpp-skip-labels +++ b/t/t4018/cpp-skip-labels @@ -1,3 +1,4 @@ +t4018 header: void RIGHT (void) void RIGHT (void) { repeat: // C++ comment diff --git a/t/t4018/cpp-struct-definition b/t/t4018/cpp-struct-definition index 521c59fd151..a0f9a16204d 100644 --- a/t/t4018/cpp-struct-definition +++ b/t/t4018/cpp-struct-definition @@ -1,3 +1,4 @@ +t4018 header: struct RIGHT { struct RIGHT { unsigned /* this bit field looks like a label and should not be picked up */ diff --git a/t/t4018/cpp-struct-single-line b/t/t4018/cpp-struct-single-line index a0de5fb800f..0d2378a320a 100644 --- a/t/t4018/cpp-struct-single-line +++ b/t/t4018/cpp-struct-single-line @@ -1,3 +1,4 @@ +t4018 header: struct RIGHT_iterator_tag {}; void wrong() { } diff --git a/t/t4018/cpp-template-function-definition b/t/t4018/cpp-template-function-definition index 0cdf5ba5bd4..f1ea1e54f5a 100644 --- a/t/t4018/cpp-template-function-definition +++ b/t/t4018/cpp-template-function-definition @@ -1,3 +1,4 @@ +t4018 header: template int RIGHT(T arg) template int RIGHT(T arg) { ChangeMe; diff --git a/t/t4018/cpp-union-definition b/t/t4018/cpp-union-definition index 7ec94df6973..6c00ab3b430 100644 --- a/t/t4018/cpp-union-definition +++ b/t/t4018/cpp-union-definition @@ -1,3 +1,4 @@ +t4018 header: union RIGHT { union RIGHT { double v; int ChangeMe; diff --git a/t/t4018/cpp-void-c-function b/t/t4018/cpp-void-c-function index 153081e872c..08765096c96 100644 --- a/t/t4018/cpp-void-c-function +++ b/t/t4018/cpp-void-c-function @@ -1,3 +1,4 @@ +t4018 header: void RIGHT (void) void RIGHT (void) { ChangeMe; diff --git a/t/t4018/css-attribute-value-selector b/t/t4018/css-attribute-value-selector index 918256b20c5..8fe8429eb02 100644 --- a/t/t4018/css-attribute-value-selector +++ b/t/t4018/css-attribute-value-selector @@ -1,3 +1,4 @@ +t4018 header: [class*="RIGHT"] { [class*="RIGHT"] { background : #000; border : 10px ChangeMe #C6C6C6; diff --git a/t/t4018/css-block-level-@-statements b/t/t4018/css-block-level-@-statements index d6755f2f3db..0ea1b9eb37c 100644 --- a/t/t4018/css-block-level-@-statements +++ b/t/t4018/css-block-level-@-statements @@ -1,3 +1,4 @@ +t4018 header: @keyframes RIGHT { @keyframes RIGHT { from { background : #000; diff --git a/t/t4018/css-brace-in-col-1 b/t/t4018/css-brace-in-col-1 index 7831577506a..8bc58ce7098 100644 --- a/t/t4018/css-brace-in-col-1 +++ b/t/t4018/css-brace-in-col-1 @@ -1,3 +1,4 @@ +t4018 header: RIGHT label.control-label RIGHT label.control-label { margin-top: 10px!important; diff --git a/t/t4018/css-class-selector b/t/t4018/css-class-selector index f790a0062f4..9b7a2b80e72 100644 --- a/t/t4018/css-class-selector +++ b/t/t4018/css-class-selector @@ -1,3 +1,4 @@ +t4018 header: .RIGHT { .RIGHT { background : #000; border : 10px ChangeMe #C6C6C6; diff --git a/t/t4018/css-colon-eol b/t/t4018/css-colon-eol index 5a30553d291..665c9f6af5b 100644 --- a/t/t4018/css-colon-eol +++ b/t/t4018/css-colon-eol @@ -1,3 +1,4 @@ +t4018 header: RIGHT h1 { RIGHT h1 { color: ChangeMe; diff --git a/t/t4018/css-colon-selector b/t/t4018/css-colon-selector index c6d71fb42de..dd0e897155f 100644 --- a/t/t4018/css-colon-selector +++ b/t/t4018/css-colon-selector @@ -1,3 +1,4 @@ +t4018 header: RIGHT a:hover { RIGHT a:hover { margin-top: 10px!important; diff --git a/t/t4018/css-common b/t/t4018/css-common index 84ed754b33b..8351eac792b 100644 --- a/t/t4018/css-common +++ b/t/t4018/css-common @@ -1,3 +1,4 @@ +t4018 header: RIGHT label.control-label { RIGHT label.control-label { margin-top: 10px!important; border : 10px ChangeMe #C6C6C6; diff --git a/t/t4018/css-id-selector b/t/t4018/css-id-selector index 17c5111052d..2a4351a4f0b 100644 --- a/t/t4018/css-id-selector +++ b/t/t4018/css-id-selector @@ -1,3 +1,4 @@ +t4018 header: #RIGHT { #RIGHT { background : #000; border : 10px ChangeMe #C6C6C6; diff --git a/t/t4018/css-long-selector-list b/t/t4018/css-long-selector-list index 7ccd25d9ed6..e5fba459290 100644 --- a/t/t4018/css-long-selector-list +++ b/t/t4018/css-long-selector-list @@ -1,3 +1,4 @@ +t4018 header: div ul#RIGHT { p.header, label.control-label, div ul#RIGHT { diff --git a/t/t4018/css-prop-sans-indent b/t/t4018/css-prop-sans-indent index a9e3c86b3c9..8ca742c91f8 100644 --- a/t/t4018/css-prop-sans-indent +++ b/t/t4018/css-prop-sans-indent @@ -1,3 +1,4 @@ +t4018 header: RIGHT, label.control-label { RIGHT, label.control-label { margin-top: 10px!important; padding: 0; diff --git a/t/t4018/css-root-selector b/t/t4018/css-root-selector index 22b958e3694..327d7630649 100644 --- a/t/t4018/css-root-selector +++ b/t/t4018/css-root-selector @@ -1,3 +1,4 @@ +t4018 header: :RIGHT { :RIGHT { background : #000; border : 10px ChangeMe #C6C6C6; diff --git a/t/t4018/css-short-selector-list b/t/t4018/css-short-selector-list index 6a0bdee336b..8a8937a5bd8 100644 --- a/t/t4018/css-short-selector-list +++ b/t/t4018/css-short-selector-list @@ -1,3 +1,4 @@ +t4018 header: label.control, div ul#RIGHT { label.control, div ul#RIGHT { margin-top: 10px!important; border : 10px ChangeMe #C6C6C6; diff --git a/t/t4018/css-trailing-space b/t/t4018/css-trailing-space index 32b5606c70f..68956baab70 100644 --- a/t/t4018/css-trailing-space +++ b/t/t4018/css-trailing-space @@ -1,3 +1,4 @@ +t4018 header: RIGHT label.control-label { RIGHT label.control-label { margin:10px; padding:10px; diff --git a/t/t4018/custom1-pattern b/t/t4018/custom1-pattern index e8fd59f884d..37a3422384b 100644 --- a/t/t4018/custom1-pattern +++ b/t/t4018/custom1-pattern @@ -1,3 +1,4 @@ +t4018 header: int special, RIGHT; public class Beer { int special, RIGHT; diff --git a/t/t4018/custom2-match-to-end-of-line b/t/t4018/custom2-match-to-end-of-line index f88ac318b79..4800bb1c568 100644 --- a/t/t4018/custom2-match-to-end-of-line +++ b/t/t4018/custom2-match-to-end-of-line @@ -1,3 +1,4 @@ +t4018 header: RIGHT_Beer public class RIGHT_Beer { int special; diff --git a/t/t4018/custom3-alternation-in-pattern b/t/t4018/custom3-alternation-in-pattern index 5f3769c64fc..bf7df3d9a73 100644 --- a/t/t4018/custom3-alternation-in-pattern +++ b/t/t4018/custom3-alternation-in-pattern @@ -1,3 +1,4 @@ +t4018 header: public static void main(String RIGHT[]) public class Beer { int special; diff --git a/t/t4018/dts-labels b/t/t4018/dts-labels index b21ef8737bb..6b907dcdedf 100644 --- a/t/t4018/dts-labels +++ b/t/t4018/dts-labels @@ -1,3 +1,4 @@ +t4018 header: label2: RIGHT { / { label_1: node1@ff00 { label2: RIGHT { diff --git a/t/t4018/dts-node-unitless b/t/t4018/dts-node-unitless index c5287d91416..990730ef6f4 100644 --- a/t/t4018/dts-node-unitless +++ b/t/t4018/dts-node-unitless @@ -1,3 +1,4 @@ +t4018 header: RIGHT { / { label_1: node1 { RIGHT { diff --git a/t/t4018/dts-nodes b/t/t4018/dts-nodes index 5a4334bb164..4bcebc85e60 100644 --- a/t/t4018/dts-nodes +++ b/t/t4018/dts-nodes @@ -1,3 +1,4 @@ +t4018 header: RIGHT@deadf00,4000 { / { label_1: node1@ff00 { RIGHT@deadf00,4000 { diff --git a/t/t4018/dts-nodes-boolean-prop b/t/t4018/dts-nodes-boolean-prop index afc6b5b404e..404cab6f0e1 100644 --- a/t/t4018/dts-nodes-boolean-prop +++ b/t/t4018/dts-nodes-boolean-prop @@ -1,3 +1,4 @@ +t4018 header: RIGHT@deadf00,4000 { / { label_1: node1@ff00 { RIGHT@deadf00,4000 { diff --git a/t/t4018/dts-nodes-comment1 b/t/t4018/dts-nodes-comment1 index 559dfce9b30..2e5cea26818 100644 --- a/t/t4018/dts-nodes-comment1 +++ b/t/t4018/dts-nodes-comment1 @@ -1,3 +1,4 @@ +t4018 header: RIGHT@deadf00,4000 /* &a comment */ { / { label_1: node1@ff00 { RIGHT@deadf00,4000 /* &a comment */ { diff --git a/t/t4018/dts-nodes-comment2 b/t/t4018/dts-nodes-comment2 index 27e9718b31c..f6cc3177958 100644 --- a/t/t4018/dts-nodes-comment2 +++ b/t/t4018/dts-nodes-comment2 @@ -1,3 +1,4 @@ +t4018 header: RIGHT@deadf00,4000 { /* a trailing comment */ / { label_1: node1@ff00 { RIGHT@deadf00,4000 { /* a trailing comment */ diff --git a/t/t4018/dts-nodes-multiline-prop b/t/t4018/dts-nodes-multiline-prop index 072d58b69dc..ac07b404975 100644 --- a/t/t4018/dts-nodes-multiline-prop +++ b/t/t4018/dts-nodes-multiline-prop @@ -1,3 +1,4 @@ +t4018 header: RIGHT@deadf00,4000 { / { label_1: node1@ff00 { RIGHT@deadf00,4000 { diff --git a/t/t4018/dts-reference b/t/t4018/dts-reference index 8f0c87d8637..bf141229e93 100644 --- a/t/t4018/dts-reference +++ b/t/t4018/dts-reference @@ -1,3 +1,4 @@ +t4018 header: &RIGHT { &label_1 { TEST = <455>; }; diff --git a/t/t4018/dts-root b/t/t4018/dts-root index 4353b8220c9..4105b0bb48a 100644 --- a/t/t4018/dts-root +++ b/t/t4018/dts-root @@ -1,3 +1,4 @@ +t4018 header: / { RIGHT /* Technically just supposed to be a slash and brace */ / { RIGHT /* Technically just supposed to be a slash and brace */ #size-cells = <1>; diff --git a/t/t4018/dts-root-comment b/t/t4018/dts-root-comment index 333a625c700..cdf2cee98db 100644 --- a/t/t4018/dts-root-comment +++ b/t/t4018/dts-root-comment @@ -1,3 +1,4 @@ +t4018 header: / { RIGHT /* Technically just supposed to be a slash and brace */ / { RIGHT /* Technically just supposed to be a slash and brace */ #size-cells = <1>; diff --git a/t/t4018/elixir-do-not-pick-end b/t/t4018/elixir-do-not-pick-end index fae08ba7e8c..cf861f81e9a 100644 --- a/t/t4018/elixir-do-not-pick-end +++ b/t/t4018/elixir-do-not-pick-end @@ -1,3 +1,4 @@ +t4018 header: defmodule RIGHT do defmodule RIGHT do end # diff --git a/t/t4018/elixir-ex-unit-test b/t/t4018/elixir-ex-unit-test index 0560a2b6971..469f1a03b71 100644 --- a/t/t4018/elixir-ex-unit-test +++ b/t/t4018/elixir-ex-unit-test @@ -1,3 +1,4 @@ +t4018 header: test "RIGHT" do defmodule Test do test "RIGHT" do assert true == true diff --git a/t/t4018/elixir-function b/t/t4018/elixir-function index d452f495a7e..139a4e1da8e 100644 --- a/t/t4018/elixir-function +++ b/t/t4018/elixir-function @@ -1,3 +1,4 @@ +t4018 header: def function(RIGHT, arg) do def function(RIGHT, arg) do # comment # comment diff --git a/t/t4018/elixir-macro b/t/t4018/elixir-macro index 4f925e9ad46..0b0f7d721bb 100644 --- a/t/t4018/elixir-macro +++ b/t/t4018/elixir-macro @@ -1,3 +1,4 @@ +t4018 header: defmacro foo(RIGHT) do defmacro foo(RIGHT) do # Code # Code diff --git a/t/t4018/elixir-module b/t/t4018/elixir-module index 91a4e7aa200..a4773f4abae 100644 --- a/t/t4018/elixir-module +++ b/t/t4018/elixir-module @@ -1,3 +1,4 @@ +t4018 header: defmodule RIGHT do defmodule RIGHT do @moduledoc """ Foo bar diff --git a/t/t4018/elixir-module-func b/t/t4018/elixir-module-func index c9910d06751..138493829b6 100644 --- a/t/t4018/elixir-module-func +++ b/t/t4018/elixir-module-func @@ -1,3 +1,4 @@ +t4018 header: def fun(RIGHT) do defmodule Foo do def fun(RIGHT) do # Code diff --git a/t/t4018/elixir-nested-module b/t/t4018/elixir-nested-module index 771ebc5c42a..296990dd2db 100644 --- a/t/t4018/elixir-nested-module +++ b/t/t4018/elixir-nested-module @@ -1,3 +1,4 @@ +t4018 header: defmodule MyApp.RIGHT do defmodule MyApp.RIGHT do @moduledoc """ Foo bar diff --git a/t/t4018/elixir-private-function b/t/t4018/elixir-private-function index 1aabe33b7a9..94428e775b5 100644 --- a/t/t4018/elixir-private-function +++ b/t/t4018/elixir-private-function @@ -1,3 +1,4 @@ +t4018 header: defp function(RIGHT, arg) do defp function(RIGHT, arg) do # comment # comment diff --git a/t/t4018/elixir-protocol b/t/t4018/elixir-protocol index 7d9173691e3..1f1dc8cb199 100644 --- a/t/t4018/elixir-protocol +++ b/t/t4018/elixir-protocol @@ -1,3 +1,4 @@ +t4018 header: defprotocol RIGHT do defprotocol RIGHT do @doc """ Calculates the size (and not the length!) of a data structure diff --git a/t/t4018/elixir-protocol-implementation b/t/t4018/elixir-protocol-implementation index f9234bbfc48..973226206d7 100644 --- a/t/t4018/elixir-protocol-implementation +++ b/t/t4018/elixir-protocol-implementation @@ -1,3 +1,4 @@ +t4018 header: defimpl RIGHT do defimpl RIGHT do # Docs # Docs diff --git a/t/t4018/fortran-block-data b/t/t4018/fortran-block-data index 63d4e21d0ad..eb0a77afade 100644 --- a/t/t4018/fortran-block-data +++ b/t/t4018/fortran-block-data @@ -1,3 +1,4 @@ +t4018 header: BLOCK DATA RIGHT BLOCK DATA RIGHT COMMON /B/ C, ChangeMe diff --git a/t/t4018/fortran-comment b/t/t4018/fortran-comment index 7b10d176588..e5e82331ebc 100644 --- a/t/t4018/fortran-comment +++ b/t/t4018/fortran-comment @@ -1,3 +1,4 @@ +t4018 header: subroutine RIGHT module a contains diff --git a/t/t4018/fortran-comment-keyword b/t/t4018/fortran-comment-keyword index e9206a53799..143aff89d73 100644 --- a/t/t4018/fortran-comment-keyword +++ b/t/t4018/fortran-comment-keyword @@ -1,3 +1,4 @@ +t4018 header: subroutine RIGHT (funcA, funcB) module a contains diff --git a/t/t4018/fortran-comment-legacy b/t/t4018/fortran-comment-legacy index 53cd062c1e5..edbac0b4148 100644 --- a/t/t4018/fortran-comment-legacy +++ b/t/t4018/fortran-comment-legacy @@ -1,3 +1,4 @@ +t4018 header: subroutine RIGHT module a contains diff --git a/t/t4018/fortran-comment-legacy-star b/t/t4018/fortran-comment-legacy-star index 2cbcdc3d8ab..be918f7b030 100644 --- a/t/t4018/fortran-comment-legacy-star +++ b/t/t4018/fortran-comment-legacy-star @@ -1,3 +1,4 @@ +t4018 header: subroutine RIGHT module a contains diff --git a/t/t4018/fortran-external-function b/t/t4018/fortran-external-function index 5a2d85d3aa4..ea4d8bcedc4 100644 --- a/t/t4018/fortran-external-function +++ b/t/t4018/fortran-external-function @@ -1,3 +1,4 @@ +t4018 header: function RIGHT(a, b) result(c) function RIGHT(a, b) result(c) integer, intent(in) :: ChangeMe diff --git a/t/t4018/fortran-external-subroutine b/t/t4018/fortran-external-subroutine index 4ce85fea132..9f662dd26b4 100644 --- a/t/t4018/fortran-external-subroutine +++ b/t/t4018/fortran-external-subroutine @@ -1,3 +1,4 @@ +t4018 header: subroutine RIGHT subroutine RIGHT real ChangeMe diff --git a/t/t4018/fortran-module b/t/t4018/fortran-module index c4b737dac3f..1882b3cd338 100644 --- a/t/t4018/fortran-module +++ b/t/t4018/fortran-module @@ -1,3 +1,4 @@ +t4018 header: module RIGHT module RIGHT use ChangeMe diff --git a/t/t4018/fortran-module-procedure b/t/t4018/fortran-module-procedure index 1ce6d854c22..51d368ba9be 100644 --- a/t/t4018/fortran-module-procedure +++ b/t/t4018/fortran-module-procedure @@ -1,3 +1,4 @@ +t4018 header: module RIGHT module RIGHT implicit none diff --git a/t/t4018/fortran-program b/t/t4018/fortran-program index 4616895e4b5..1c84e1ff0f8 100644 --- a/t/t4018/fortran-program +++ b/t/t4018/fortran-program @@ -1,3 +1,4 @@ +t4018 header: program RIGHT program RIGHT call ChangeMe diff --git a/t/t4018/fountain-scene b/t/t4018/fountain-scene index 6b3257d6803..2ffcf799087 100644 --- a/t/t4018/fountain-scene +++ b/t/t4018/fountain-scene @@ -1,3 +1,4 @@ +t4018 header: EXT. STREET RIGHT OUTSIDE - DAY EXT. STREET RIGHT OUTSIDE - DAY CHARACTER diff --git a/t/t4018/golang-complex-function b/t/t4018/golang-complex-function index e057dcefed6..0574ba912e6 100644 --- a/t/t4018/golang-complex-function +++ b/t/t4018/golang-complex-function @@ -1,3 +1,4 @@ +t4018 header: func (t *Test) RIGHT(a Type) (Type, error) { type Test struct { a Type } diff --git a/t/t4018/golang-func b/t/t4018/golang-func index 8e9c9ac7c3f..0472cfd9798 100644 --- a/t/t4018/golang-func +++ b/t/t4018/golang-func @@ -1,3 +1,4 @@ +t4018 header: func RIGHT() { func RIGHT() { a := 5 b := ChangeMe diff --git a/t/t4018/golang-interface b/t/t4018/golang-interface index 553bedec962..3160a1d4524 100644 --- a/t/t4018/golang-interface +++ b/t/t4018/golang-interface @@ -1,3 +1,4 @@ +t4018 header: type RIGHT interface { type RIGHT interface { a() Type b() ChangeMe diff --git a/t/t4018/golang-long-func b/t/t4018/golang-long-func index ac3a77b5c41..de83aaafca5 100644 --- a/t/t4018/golang-long-func +++ b/t/t4018/golang-long-func @@ -1,3 +1,4 @@ +t4018 header: func RIGHT(aVeryVeryVeryLongVariableName AVeryVeryVeryLongType, func RIGHT(aVeryVeryVeryLongVariableName AVeryVeryVeryLongType, anotherLongVariableName AnotherLongType) { a := 5 diff --git a/t/t4018/golang-struct b/t/t4018/golang-struct index 5deda77feec..fc8022537b2 100644 --- a/t/t4018/golang-struct +++ b/t/t4018/golang-struct @@ -1,3 +1,4 @@ +t4018 header: type RIGHT struct { type RIGHT struct { a Type b ChangeMe diff --git a/t/t4018/java-class-member-function b/t/t4018/java-class-member-function index 298bc7a71b2..df77bd71f79 100644 --- a/t/t4018/java-class-member-function +++ b/t/t4018/java-class-member-function @@ -1,3 +1,4 @@ +t4018 header: public static void main(String RIGHT[]) public class Beer { int special; diff --git a/t/t4018/markdown-heading-indented b/t/t4018/markdown-heading-indented index 1991c2bd456..e68801c7c06 100644 --- a/t/t4018/markdown-heading-indented +++ b/t/t4018/markdown-heading-indented @@ -1,3 +1,4 @@ +t4018 header: ### RIGHT Indented headings are allowed, as long as the indent is no more than 3 spaces. ### RIGHT diff --git a/t/t4018/markdown-heading-non-headings b/t/t4018/markdown-heading-non-headings index c479c1a3f1e..00d677ebe95 100644 --- a/t/t4018/markdown-heading-non-headings +++ b/t/t4018/markdown-heading-non-headings @@ -1,3 +1,4 @@ +t4018 header: # RIGHT Headings can be right next to other lines of the file: # RIGHT Indents of four or more spaces make a code block: diff --git a/t/t4018/matlab-class-definition b/t/t4018/matlab-class-definition index 84daedfb4e5..86b48eebe0a 100644 --- a/t/t4018/matlab-class-definition +++ b/t/t4018/matlab-class-definition @@ -1,3 +1,4 @@ +t4018 header: classdef RIGHT classdef RIGHT properties ChangeMe diff --git a/t/t4018/matlab-function b/t/t4018/matlab-function index 897a9b13ff4..9a93efffb99 100644 --- a/t/t4018/matlab-function +++ b/t/t4018/matlab-function @@ -1,3 +1,4 @@ +t4018 header: function y = RIGHT() function y = RIGHT() x = 5; y = ChangeMe + x; diff --git a/t/t4018/matlab-octave-section-1 b/t/t4018/matlab-octave-section-1 index 3bb6c4670e2..b896cb07ff1 100644 --- a/t/t4018/matlab-octave-section-1 +++ b/t/t4018/matlab-octave-section-1 @@ -1,3 +1,4 @@ +t4018 header: %%% RIGHT section %%% RIGHT section # this is octave script ChangeMe = 1; diff --git a/t/t4018/matlab-octave-section-2 b/t/t4018/matlab-octave-section-2 index ab2980f7f29..4e75942678f 100644 --- a/t/t4018/matlab-octave-section-2 +++ b/t/t4018/matlab-octave-section-2 @@ -1,3 +1,4 @@ +t4018 header: ## RIGHT section ## RIGHT section # this is octave script ChangeMe = 1; diff --git a/t/t4018/matlab-section b/t/t4018/matlab-section index 5ea59a5de00..6b45ae20009 100644 --- a/t/t4018/matlab-section +++ b/t/t4018/matlab-section @@ -1,3 +1,4 @@ +t4018 header: %% RIGHT section %% RIGHT section % this is understood by both matlab and octave ChangeMe = 1; diff --git a/t/t4018/perl-skip-end-of-heredoc b/t/t4018/perl-skip-end-of-heredoc index c22d39b2567..8f90cca7314 100644 --- a/t/t4018/perl-skip-end-of-heredoc +++ b/t/t4018/perl-skip-end-of-heredoc @@ -1,3 +1,4 @@ +t4018 header: sub RIGHTwithheredocument { sub RIGHTwithheredocument { print <<"EOF" decoy here-doc diff --git a/t/t4018/perl-skip-forward-decl b/t/t4018/perl-skip-forward-decl index a98cb8bdad0..ff1f6d14735 100644 --- a/t/t4018/perl-skip-forward-decl +++ b/t/t4018/perl-skip-forward-decl @@ -1,3 +1,4 @@ +t4018 header: package RIGHT; package RIGHT; use strict; diff --git a/t/t4018/perl-skip-sub-in-pod b/t/t4018/perl-skip-sub-in-pod index e39f02462e2..ff1c65b28fc 100644 --- a/t/t4018/perl-skip-sub-in-pod +++ b/t/t4018/perl-skip-sub-in-pod @@ -1,3 +1,4 @@ +t4018 header: =head1 SYNOPSIS_RIGHT =head1 NAME Beer - subroutine to output fragment of a drinking song diff --git a/t/t4018/perl-sub-definition b/t/t4018/perl-sub-definition index a507d1f6452..22e16ad5363 100644 --- a/t/t4018/perl-sub-definition +++ b/t/t4018/perl-sub-definition @@ -1,3 +1,4 @@ +t4018 header: sub RIGHT { sub RIGHT { my ($n) = @_; print "ChangeMe"; diff --git a/t/t4018/perl-sub-definition-kr-brace b/t/t4018/perl-sub-definition-kr-brace index 330b3df1142..6c94e6a62dd 100644 --- a/t/t4018/perl-sub-definition-kr-brace +++ b/t/t4018/perl-sub-definition-kr-brace @@ -1,3 +1,4 @@ +t4018 header: sub RIGHT sub RIGHT { print "ChangeMe\n"; diff --git a/t/t4018/php-abstract-class b/t/t4018/php-abstract-class index 5213e124946..fbc97843c6b 100644 --- a/t/t4018/php-abstract-class +++ b/t/t4018/php-abstract-class @@ -1,3 +1,4 @@ +t4018 header: abstract class RIGHT abstract class RIGHT { const FOO = 'ChangeMe'; diff --git a/t/t4018/php-abstract-method b/t/t4018/php-abstract-method index ce215df75a4..22f5120d3b7 100644 --- a/t/t4018/php-abstract-method +++ b/t/t4018/php-abstract-method @@ -1,3 +1,4 @@ +t4018 header: abstract public function RIGHT(): ?string abstract class Klass { abstract public function RIGHT(): ?string diff --git a/t/t4018/php-class b/t/t4018/php-class index 7785b6303c7..42456cda768 100644 --- a/t/t4018/php-class +++ b/t/t4018/php-class @@ -1,3 +1,4 @@ +t4018 header: class RIGHT class RIGHT { const FOO = 'ChangeMe'; diff --git a/t/t4018/php-final-class b/t/t4018/php-final-class index 69f57105529..ccf2d28a2d8 100644 --- a/t/t4018/php-final-class +++ b/t/t4018/php-final-class @@ -1,3 +1,4 @@ +t4018 header: final class RIGHT final class RIGHT { const FOO = 'ChangeMe'; diff --git a/t/t4018/php-final-method b/t/t4018/php-final-method index 537fb8ad9ae..55107faef98 100644 --- a/t/t4018/php-final-method +++ b/t/t4018/php-final-method @@ -1,3 +1,4 @@ +t4018 header: final public function RIGHT(): string class Klass { final public function RIGHT(): string diff --git a/t/t4018/php-function b/t/t4018/php-function index 35717c51c3b..f021285e385 100644 --- a/t/t4018/php-function +++ b/t/t4018/php-function @@ -1,3 +1,4 @@ +t4018 header: function RIGHT() function RIGHT() { return 'ChangeMe'; diff --git a/t/t4018/php-interface b/t/t4018/php-interface index 86b49ad5d9e..ef48244eaa8 100644 --- a/t/t4018/php-interface +++ b/t/t4018/php-interface @@ -1,3 +1,4 @@ +t4018 header: interface RIGHT interface RIGHT { public function foo($ChangeMe); diff --git a/t/t4018/php-method b/t/t4018/php-method index 03af1a6d9d7..cbc171a99b9 100644 --- a/t/t4018/php-method +++ b/t/t4018/php-method @@ -1,3 +1,4 @@ +t4018 header: public static function RIGHT() class Klass { public static function RIGHT() diff --git a/t/t4018/php-trait b/t/t4018/php-trait index 65b8c82a616..cba65191d39 100644 --- a/t/t4018/php-trait +++ b/t/t4018/php-trait @@ -1,3 +1,4 @@ +t4018 header: trait RIGHT trait RIGHT { public function foo($ChangeMe) diff --git a/t/t4018/python-async-def b/t/t4018/python-async-def index 87640e03d21..facfaeef373 100644 --- a/t/t4018/python-async-def +++ b/t/t4018/python-async-def @@ -1,3 +1,4 @@ +t4018 header: async def RIGHT(pi: int = 3.14): async def RIGHT(pi: int = 3.14): while True: break diff --git a/t/t4018/python-class b/t/t4018/python-class index ba9e741430f..87153873b4f 100644 --- a/t/t4018/python-class +++ b/t/t4018/python-class @@ -1,3 +1,4 @@ +t4018 header: class RIGHT(int, str): class RIGHT(int, str): # comment # another comment diff --git a/t/t4018/python-def b/t/t4018/python-def index e50b31b0ad5..08fb9a6b4ec 100644 --- a/t/t4018/python-def +++ b/t/t4018/python-def @@ -1,3 +1,4 @@ +t4018 header: def RIGHT(pi: int = 3.14): def RIGHT(pi: int = 3.14): while True: break diff --git a/t/t4018/python-indented-async-def b/t/t4018/python-indented-async-def index f5d03258af4..f604d08028f 100644 --- a/t/t4018/python-indented-async-def +++ b/t/t4018/python-indented-async-def @@ -1,3 +1,4 @@ +t4018 header: async def RIGHT(self, x: int): class Foo: async def RIGHT(self, x: int): return [ diff --git a/t/t4018/python-indented-class b/t/t4018/python-indented-class index 19b4f35c4ca..65c07f74f6f 100644 --- a/t/t4018/python-indented-class +++ b/t/t4018/python-indented-class @@ -1,3 +1,4 @@ +t4018 header: class RIGHT: if TYPE_CHECKING: class RIGHT: # comment diff --git a/t/t4018/python-indented-def b/t/t4018/python-indented-def index 208fbadd2be..be87764e31b 100644 --- a/t/t4018/python-indented-def +++ b/t/t4018/python-indented-def @@ -1,3 +1,4 @@ +t4018 header: def RIGHT(self, x: int): class Foo: def RIGHT(self, x: int): return [ diff --git a/t/t4018/rust-fn b/t/t4018/rust-fn index cbe02155f11..939b131ea80 100644 --- a/t/t4018/rust-fn +++ b/t/t4018/rust-fn @@ -1,3 +1,4 @@ +t4018 header: pub(self) fn RIGHT(x: &[T]) where T: Debug { pub(self) fn RIGHT(x: &[T]) where T: Debug { let _ = x; // a comment diff --git a/t/t4018/rust-impl b/t/t4018/rust-impl index 09df3cd93b2..1f798a43d38 100644 --- a/t/t4018/rust-impl +++ b/t/t4018/rust-impl @@ -1,3 +1,4 @@ +t4018 header: impl<'a, T: AsRef<[u8]>> std::RIGHT for Git<'a> { impl<'a, T: AsRef<[u8]>> std::RIGHT for Git<'a> { pub fn ChangeMe(&self) -> () { diff --git a/t/t4018/rust-macro-rules b/t/t4018/rust-macro-rules index ec610c5b62b..3990daf0e90 100644 --- a/t/t4018/rust-macro-rules +++ b/t/t4018/rust-macro-rules @@ -1,3 +1,4 @@ +t4018 header: macro_rules! RIGHT { macro_rules! RIGHT { () => { // a comment diff --git a/t/t4018/rust-struct b/t/t4018/rust-struct index 76aff1c0d8e..8c901a437cb 100644 --- a/t/t4018/rust-struct +++ b/t/t4018/rust-struct @@ -1,3 +1,4 @@ +t4018 header: pub(super) struct RIGHT<'a> { #[derive(Debug)] pub(super) struct RIGHT<'a> { name: &'a str, diff --git a/t/t4018/rust-trait b/t/t4018/rust-trait index ea397f09ed1..4cc9714e8f0 100644 --- a/t/t4018/rust-trait +++ b/t/t4018/rust-trait @@ -1,3 +1,4 @@ +t4018 header: unsafe trait RIGHT { unsafe trait RIGHT { fn len(&self) -> u32; fn ChangeMe(&self, n: u32) -> T; From patchwork Wed Feb 24 19:51:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102365 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=-15.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,USER_AGENT_GIT 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 D89AEC433E0 for ; Wed, 24 Feb 2021 19:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A15E764EDD for ; Wed, 24 Feb 2021 19:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235158AbhBXTyC (ORCPT ); Wed, 24 Feb 2021 14:54:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234839AbhBXTxV (ORCPT ); Wed, 24 Feb 2021 14:53:21 -0500 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 EBD8CC0617A9 for ; Wed, 24 Feb 2021 11:52:03 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id k66so2910872wmf.1 for ; Wed, 24 Feb 2021 11:52:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bnTVyCm1E81e8pQqNWVBhz318SyFao3a8UZxmQjUzAg=; b=TEf6yZ6vEsZIdhHk8QUPuN4kFTJ+ZagK+bjOjv/4FmhTCtd7exixtSCrAVJXWfCgp4 5YtXCEEw8cVCrT7tUKk5WD7s1Iw/yW/c0mLQQwxOtr6ddbfSVW4ulHmXKASs5jFcV7mK hVlurwuKrzUUtIgWhvLz2zx8K6stx18xyPDaQjRBnWUcQ1Y7c4udS5M4TjM1ze8t4xui QVrk1Kft9YpuAL8s2jvRpA+DwIj/Ff8Bcnp478LWYqfnDQutjMpM2WrDOLOyDhrsBj5i +gmF6jI4gJxXwgwJZ++7CvdPrBo9l94vJuLYhQ7983oVKugaqh69G6hL95C7JIwBNlZ7 b6lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bnTVyCm1E81e8pQqNWVBhz318SyFao3a8UZxmQjUzAg=; b=ZA1O9HiK3IL8Kq/m0ItsDyjZbi1ZbxD4E4Y9zKnI7azbY0r4yjBk8oSgm51aJk8wuG l24xFUhKdVN3/6w46Vu+IOJvwQur6YduJUUtc1oRLWfhYBnjHkt13zgKDl5eFg17uOQu fkqBlm19DNWw0o4np7HVEJGlGf78q3b7vFbQD1ybx1WF8sjWWyJvdkb/F9X95D5TFATn qKu2nmMnicF9aucvR9zACeNy53lxSRbWHGEs70whbQ9qgksi8xnI7WpjdfJIvrF0DFRO lscqKzNNOgFsMC4nUlinfP2BbGUen2ZV34G9PVqkE4igJxomd0Ms7X94bKXGWO3HiALd 1axQ== X-Gm-Message-State: AOAM530zA7k8Rn2p1XN/LJpmzI7BuYHLOQlxukyqS0+XTaAMZxUdQkYP AyI4Yo9kRQhXTCyKOZNBtEufz2G2QN66lQ== X-Google-Smtp-Source: ABdhPJxIbA+HUL4DQjyQCFV8vbh/AFGToM8SvHFl2h3Fwm2PefY9OGq8FuK8Hcsdt4p9eN2I/nGuUA== X-Received: by 2002:a05:600c:4fd0:: with SMTP id o16mr5213075wmq.77.1614196322419; Wed, 24 Feb 2021 11:52:02 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:02 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 12/35] userdiff tests: change setup loop to individual test setup Date: Wed, 24 Feb 2021 20:51:06 +0100 Message-Id: <20210224195129.4004-13-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the recently amended setup loop in "setup hunk header tests" to instead set up the test data as we test each individual hunk header test. This means we can get rid of the "|| return 1" case and the previous for-loop, and won't spend time on setting up all the data only to e.g. fail on the 1st test when running under "-i". Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 15dcbe735ca..2365f0e361e 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -72,24 +72,23 @@ test_expect_success 'setup hunk header tests' ' cp -R "$TEST_DIRECTORY"/t4018 . && git init t4018 && - git -C t4018 add . && + git -C t4018 add . +' - for i in $(git -C t4018 ls-files) - do - grep -v "^t4018" "t4018/$i" >"t4018/$i.content" && - sed -n -e "s/^t4018 header: //p" <"t4018/$i" >"t4018/$i.header" && - cp "t4018/$i.content" "$i" && +# check each individual file +for i in $(git -C t4018 ls-files) +do + test_expect_success "setup hunk header: $i" " + grep -v '^t4018' \"t4018/$i\" >\"t4018/$i.content\" && + sed -n -e 's/^t4018 header: //p' <\"t4018/$i\" >\"t4018/$i.header\" && + cp \"t4018/$i.content\" \"$i\" && # add test file to the index - git add "$i" && + git add \"$i\" && # place modified file in the worktree - sed -e "s/ChangeMe/IWasChanged/" <"t4018/$i.content" >"$i" || return 1 - done -' + sed -e 's/ChangeMe/IWasChanged/' <\"t4018/$i.content\" >\"$i\" + " -# check each individual file -for i in $(git ls-files) -do test_expect_success "hunk header: $i" " git diff -U1 $i >diff && sed -n -e 's/^.*@@$//p' -e 's/^.*@@ //p' ctx && From patchwork Wed Feb 24 19:51:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102383 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=-15.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,USER_AGENT_GIT 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 99C18C433DB for ; Wed, 24 Feb 2021 19:55:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FC1E64F06 for ; Wed, 24 Feb 2021 19:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235166AbhBXTzr (ORCPT ); Wed, 24 Feb 2021 14:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235172AbhBXTxh (ORCPT ); Wed, 24 Feb 2021 14:53:37 -0500 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 DBE5FC0617AB for ; Wed, 24 Feb 2021 11:52:04 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id v15so3049472wrx.4 for ; Wed, 24 Feb 2021 11:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YZ9RBdohkPzJ0/hq4JRsvjAEH5e3qtgkKeHPFQHDpV8=; b=ARw411qHtIoagoqjo/LoFfJki0cTR7rTMPCRADZMAzg8veJBOJWhdghKjQXVdKqZAG 7zF5kad2qy2x1ODFMFnhLTPSBGEXYipcjhGYHeSdVrVPwPBnJwwStjm0asKWNL9Nj/qp 0ZxTa9+iqR1J3mr+O0d6E4t+OAfgsRmXfRffC8QpDBloNPBp4rSkd8LtMWB8trOIuBFQ aJe2HzAo03NY3giTm125T8JfQ8MlXV8C2S2aSK6RxaxQSF8W1hxjes2lF6mIvG7OYxmq YSMc7IgiIWfxBOtBRlg7Ii8xCyEpOvAyem1TD1sWQ39JQKAcNBk4+wWPeh/U9VtsHxy3 YdYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YZ9RBdohkPzJ0/hq4JRsvjAEH5e3qtgkKeHPFQHDpV8=; b=DT/5ZfCg/waltcp2v2Vfh5x1rvRpXB4lRg3kKs6N5k6mgZZjiXoyIIkJ5fn8wV2lys J37M0oG2RD90ufjIC1wPBCAxoIE1r3q+ECESzAx0HRIbuoFacz+COkIxKQYIdLh85Cz/ Toi+LCNPUjS3rUmYFr3IkqNMxv6EmHrRbVZCu3zICa6cOZkOn7LAjnKfkL2IZy5h197q wM9mcIcRzxTmUmeYzGynj+9fmMzM1eyeDupmYGDcMnZ7BjSPMuUuuu/2kCZfyamdwaWd tMDLsq58XR85vYhRxlhReGcfVYpAh4QBXKNRfsmHrQfbXRVSmbEPbrb7Sz6QEYjS+5QG oCTw== X-Gm-Message-State: AOAM531xqJ95HMNzKNwIf4tfF27prtPoBZavuW+oCVQtt9iW5nGlw9wJ 2Dw9747NKW9k2lu4djpnh+FxVNCcN5rCUw== X-Google-Smtp-Source: ABdhPJxpI5ZXN+q+0hV2Zy2dQvafYoLjY2fSGVNxLwRkaXdNKcgbjkw4AfUMv3HDKjRxk1OHbm1cKQ== X-Received: by 2002:adf:bc01:: with SMTP id s1mr3417154wrg.240.1614196323390; Wed, 24 Feb 2021 11:52:03 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:02 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 13/35] userdiff tests: factor out test_diff_funcname() logic Date: Wed, 24 Feb 2021 20:51:07 +0100 Message-Id: <20210224195129.4004-14-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Factor out logic in test_diff_funcname() into two helper functions, these will be useful in a follow-up commit where we'll do this munging in more than one place. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 2365f0e361e..8a8a7a99c88 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -75,6 +75,17 @@ test_expect_success 'setup hunk header tests' ' git -C t4018 add . ' +do_change_me () { + file=$1 + sed -e "s/ChangeMe/IWasChanged/" <"$file" >tmp && + mv tmp "$file" +} + +last_diff_context_line () { + file=$1 + sed -n -e "s/^.*@@$//p" -e "s/^.*@@ //p" <$file +} + # check each individual file for i in $(git -C t4018 ls-files) do @@ -85,13 +96,12 @@ do # add test file to the index git add \"$i\" && - # place modified file in the worktree - sed -e 's/ChangeMe/IWasChanged/' <\"t4018/$i.content\" >\"$i\" + do_change_me \"$i\" " test_expect_success "hunk header: $i" " git diff -U1 $i >diff && - sed -n -e 's/^.*@@$//p' -e 's/^.*@@ //p' ctx && + last_diff_context_line diff >ctx && test_cmp t4018/$i.header ctx " done From patchwork Wed Feb 24 19:51:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102385 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=-15.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,USER_AGENT_GIT 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 154B5C433E0 for ; Wed, 24 Feb 2021 19:56:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D67C464F06 for ; Wed, 24 Feb 2021 19:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233765AbhBXTz4 (ORCPT ); Wed, 24 Feb 2021 14:55:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235175AbhBXTxi (ORCPT ); Wed, 24 Feb 2021 14:53:38 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2474C061356 for ; Wed, 24 Feb 2021 11:52:05 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id c7so3040040wru.8 for ; Wed, 24 Feb 2021 11:52:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cG+uULvfiuwIQgvSVTGYx2ppDe1gnVP8ks4c6FgYZio=; b=bgRMXNl5x04bCvwdnI2ccRKHb4iI35D2kTgwInTb32EiskH4eEf6pWdKkiNnWIYedU JIBhR1uFrhCJg5rGaCxi2jrUnLfzfSjvrEGPoMZZbCv+MdQuE+qu3XQatqAm5QXpS1Ol zNaYTtxKkT3sMyLj82ZN/fT7eXP5Av6pzyRAXhmVmYGWILHf+oM9YLZTxv+MBjc8KIsZ GPGDKoJBx6olR8w4kSbyM6GZ93+zIWWNC7WcAKO5F2QHRuPXsJ+9qKxwCL8HSQ/xz2rs A9+ZEz2VVodXO/Sks4kK1MD6S04dOa8aRUuQqBdZmlPxSpqWoxJ107qxPjn7FSgPXtBk yaWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cG+uULvfiuwIQgvSVTGYx2ppDe1gnVP8ks4c6FgYZio=; b=GGP/KceYkizEFZytTQR/ygfVYKR7JzK7DBH4fcxgcVo61c0TYG6bemTvHgggdfdOwi Clfi1zYrfeXkL7DbcLjvFUXxAr407DlBzOVGva0qUlbxSt+zhcJTA+UkO3xQCxN/yinv 6IHTGVKzh10ZR7XYWCmKWz+eQrNdM3kl0TXPo1KdpVkfJ30Cl50jNqH9kOPcn/mJvH1t IZlQrzUK2h00eZYN2zNUIPXKkE5NXtZMZi70ONCTV4TV6Nqu/A8szKbcKgvJnqCQCLlX VhJRRQy9kAi2ztJxQOg664X917jHRSgd7vA9XxZ6/TwTRh3ub3UnYD3Knp8CSd8kDrIx 0R8w== X-Gm-Message-State: AOAM533qROJmcNReVBEHgTwip92fevVUh+PuKgSBDTWR1cKkDw/c8G+U XdsdisfuMa12wT4wXbSV/H0iCFuOWZ3YNQ== X-Google-Smtp-Source: ABdhPJyzhvCfM5//hrtfmHTipKi8x7goMZCi8A/sBQ+PtID7VP1exozQKk9jTUGEpFzpgJtWbFbYvg== X-Received: by 2002:a5d:4c45:: with SMTP id n5mr13520315wrt.370.1614196324236; Wed, 24 Feb 2021 11:52:04 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:03 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 14/35] userdiff tests: add alternative hunk header test infrastructure Date: Wed, 24 Feb 2021 20:51:08 +0100 Message-Id: <20210224195129.4004-15-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add an alternative to the hunk header test infrastructure introduced in bfa7d01413 (t4018: an infrastructure to test hunk headers, 2014-03-21). See c228a5c077 (Merge branch 'js/userdiff-cc', 2014-03-31) for the whole series that commit was part of. As noted in an earlier commit that change introduced the regression of not testing for the full hunk line, but just whether "RIGHT" appeared on it. A preceding commit fixed that specific issue, but we are still left with the inflexibility of not being able to do any testing except that which fits inside the narrow confines of this custom test syntax, e.g. being unable to setup config variables before specific tests. So introduce a new "test_diff_funcname()" function which is expected to be used by tests in t4018/*.sh, and move the "custom" tests over to that. As will be seen in follow-up changes we'll make use of this new function infrastructure in the "custom" tests. There's no reason for not moving all of the tests over to this new infrastructure as far as test coverage goes, but Junio and Johannes expressed a desire to keep the existing test mode [1], so I'm only moving a narrow set of tests over to the new mode. 1. https://lore.kernel.org/git/xmqqsg5vrhha.fsf@gitster.c.googlers.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 38 +++++++++++++++- t/t4018/README | 44 ++++++++++++++++--- t/t4018/{custom1-pattern => custom1.sh} | 11 ++++- t/t4018/custom2-match-to-end-of-line | 9 ---- t/t4018/custom2.sh | 18 ++++++++ ...tom3-alternation-in-pattern => custom3.sh} | 11 ++++- 6 files changed, 113 insertions(+), 18 deletions(-) rename t/t4018/{custom1-pattern => custom1.sh} (71%) mode change 100644 => 100755 delete mode 100644 t/t4018/custom2-match-to-end-of-line create mode 100755 t/t4018/custom2.sh rename t/t4018/{custom3-alternation-in-pattern => custom3.sh} (66%) mode change 100644 => 100755 diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 8a8a7a99c88..6fd3dce1364 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -87,7 +87,7 @@ last_diff_context_line () { } # check each individual file -for i in $(git -C t4018 ls-files) +for i in $(git -C t4018 ls-files -- ':!*.sh') do test_expect_success "setup hunk header: $i" " grep -v '^t4018' \"t4018/$i\" >\"t4018/$i.content\" && @@ -106,4 +106,40 @@ do " done +test_diff_funcname () { + desc=$1 + cat <&8 >arg.header && + cat <&9 >arg.test && + what=$(cat arg.what) && + + test_expect_success "setup: $desc" ' + cp arg.test "$what" && + cp arg.header expected && + git add "$what" && + do_change_me "$what" + ' && + + test_expect_success "$desc" ' + git diff -U1 "$what" >diff && + last_diff_context_line diff >actual && + test_cmp expected actual + ' +} + +for what in $diffpatterns +do + test="$TEST_DIRECTORY/t4018/$what.sh" + if ! test -e "$test" + then + continue + fi && + + test_expect_success "setup: hunk header for $what" ' + echo "$what diff=$what" >.gitattributes && + echo "$what" >arg.what + ' && + + . "$test" +done + test_done diff --git a/t/t4018/README b/t/t4018/README index 0a246bbc10e..54ae735d5f8 100644 --- a/t/t4018/README +++ b/t/t4018/README @@ -1,13 +1,45 @@ -t4018 header: description of the test. +t4018 header: There are two ways of writing tests in this directory. In both cases How to write test cases ======================= -Create test cases called "LANG-whatever" in this directory, where -"LANG" is e.g. the userdiff driver name, where "whatever" is a brief -description of the test. +There are two ways of writing tests in this directory. In both cases +"LANG" is the userdiff driver name, e.g. "perl" or "cpp". + +The word "ChangeMe" (exactly this form) should appear at a distance of +at least two lines from the line that must appear in the hunk +header. See below sections. + +t4018 header: t/README. +"LANG.sh" test cases +==================== + +These tests use the normal test-lib.sh syntax and environment, and are +sourced by t4018-diff-funcname.sh. The "test_diff_funcname()" function +is a thin wrapper around the "test_expect_success()" function. See +t/README. + +The content of the "EOF_TEST" argument is used as-is, with the +exception of the "ChangeMe" token discussed above. + +The advantage of using this over the "LANG-whatever" test cases (see +below) are: -Insert the word "ChangeMe" (exactly this form) at a distance of -at least two lines from the line that must appear in the hunk header. + - The ability to do custom test setup/teardown, e.g. using + "test_config" before the test is run. + + - The description of the test is a string, and doesn't need to be a + valid filename. + + - All the tests for a given driver are present in one file. As + demonstrated with the two "t4018 header" lines in this file this is + also possible with the "LANG-whatever" tests, but those N tests in + one file won't benefit from different test descriptions. + +"LANG-whatever" test cases +========================== + +Create test cases called "LANG-whatever" in this directory, where +"whatever" is a brief description of the test. Any line starting with "t4018" is a control line for the test: diff --git a/t/t4018/custom1-pattern b/t/t4018/custom1.sh old mode 100644 new mode 100755 similarity index 71% rename from t/t4018/custom1-pattern rename to t/t4018/custom1.sh index 37a3422384b..f8bbccadb47 --- a/t/t4018/custom1-pattern +++ b/t/t4018/custom1.sh @@ -1,4 +1,12 @@ -t4018 header: int special, RIGHT; +#!/bin/sh +# +# See ../t4018-diff-funcname.sh's test_diff_funcname() +# + +test_diff_funcname 'custom1: pattern' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +int special, RIGHT; +EOF_HUNK public class Beer { int special, RIGHT; @@ -16,3 +24,4 @@ public class Beer + "99 bottles of beer on the wall.\n"); } } +EOF_TEST diff --git a/t/t4018/custom2-match-to-end-of-line b/t/t4018/custom2-match-to-end-of-line deleted file mode 100644 index 4800bb1c568..00000000000 --- a/t/t4018/custom2-match-to-end-of-line +++ /dev/null @@ -1,9 +0,0 @@ -t4018 header: RIGHT_Beer -public class RIGHT_Beer -{ - int special; - public static void main(String args[]) - { - System.out.print("ChangeMe"); - } -} diff --git a/t/t4018/custom2.sh b/t/t4018/custom2.sh new file mode 100755 index 00000000000..c68421f788e --- /dev/null +++ b/t/t4018/custom2.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# +# See ../t4018-diff-funcname.sh's test_diff_funcname() +# + +test_diff_funcname 'custom2: match to end of line' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +RIGHT_Beer +EOF_HUNK +public class RIGHT_Beer +{ + int special; + public static void main(String args[]) + { + System.out.print("ChangeMe"); + } +} +EOF_TEST diff --git a/t/t4018/custom3-alternation-in-pattern b/t/t4018/custom3.sh old mode 100644 new mode 100755 similarity index 66% rename from t/t4018/custom3-alternation-in-pattern rename to t/t4018/custom3.sh index bf7df3d9a73..07c5c134ffe --- a/t/t4018/custom3-alternation-in-pattern +++ b/t/t4018/custom3.sh @@ -1,4 +1,12 @@ -t4018 header: public static void main(String RIGHT[]) +#!/bin/sh +# +# See ../t4018-diff-funcname.sh's test_diff_funcname() +# + +test_diff_funcname 'custom3: alternation in pattern' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +public static void main(String RIGHT[]) +EOF_HUNK public class Beer { int special; @@ -16,3 +24,4 @@ public class Beer + "99 bottles of beer on the wall.\n"); } } +EOF_TEST From patchwork Wed Feb 24 19:51:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102367 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=-15.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,USER_AGENT_GIT 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 01D1CC433E6 for ; Wed, 24 Feb 2021 19:54:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9D8B64F03 for ; Wed, 24 Feb 2021 19:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235274AbhBXTya (ORCPT ); Wed, 24 Feb 2021 14:54:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbhBXTxc (ORCPT ); Wed, 24 Feb 2021 14:53:32 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFCB4C06121D for ; Wed, 24 Feb 2021 11:52:06 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id w7so2795943wmb.5 for ; Wed, 24 Feb 2021 11:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/UQOkgSV7OPMPxjT6137j242ZmqWH5XPLBxYUF7iDnU=; b=THdio5u+f2nBwY1cFUW8dexGTLqGyVMuQBY34ioX8gg04Q9BT87cyQjqsaW5a1fYXH cMx7uvL3Mdie8XlmE/4HToVj65IlvcKi9AwUZnVVbfEIH3bToD5Ilm96i0Z8m9DjXhTy icCuR6suPhd/68CdtZRCdjUpcfwg0OorGTT8DpInEO825YD/mQKQ7IDTmZ4wi7U84EMC cLp0F6vrY6RdsIz+c80Tk40UrjoH3i9pu1xdFEveUuvVzAR/o5iMyULplP7gL0v1owpJ 7znVGPv/MvAG1XWiCY0UE3w9ZIJvN6yn15GFlgbjMML1zUHoNT7utCizAQtQxwygI5rc OAzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/UQOkgSV7OPMPxjT6137j242ZmqWH5XPLBxYUF7iDnU=; b=J1yz7J6ZYInUvTzVHHIcgXoSp5HfB2wqGRK6jmX8mj8Tdg4dH/JYdjQ65N4A+GCNWV 6+9vUU0xCgt4CuKWB3Z2sJJij918XnvtGKaJhRL24MH2LO7heV8GRsZBRyekpsdjJ+nd C+MnhErwHhbU7S52+nkx3q7D+zvy99d4QAPaVV8C8Pku25CDlu3n5y/R6JmVNNM+8VRn C6oqBnMFvgEFmeAP6BjQ16G+pqE1m1JZ7j26PLZZv85BAGVZlquzW4ixGSvReER7zK0L OANkp1DCJwjpTe0BE9+Y5JqF0YF0HRRYABo1nJIWGXeSW+nm2FpbYqxpYTQQz9uR8F4W GqiA== X-Gm-Message-State: AOAM533dcRmoxkOn98VMyZ0Yq70inHupSeVypZGRoJsM/JU2OZZJmaDq WUJ2LuoUgwNGd5M1Rujb/7b5rVAScq0QwA== X-Google-Smtp-Source: ABdhPJyAEez0OwjUqvU4fzbFIf/hZI3bjEnrL7oGhz1cD0akFH0tfWa3YESbQdY4dgHjKgOtEwPlQA== X-Received: by 2002:a1c:cc14:: with SMTP id h20mr5236252wmb.14.1614196325111; Wed, 24 Feb 2021 11:52:05 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:04 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 15/35] userdiff tests: add a test with multiple tests in a LANG file Date: Wed, 24 Feb 2021 20:51:09 +0100 Message-Id: <20210224195129.4004-16-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Demonstrate that we can now have tests with multiple tests in a given LANG file. This is useful to show rules that don't match, follow-up commits will add some tests like that. Let's move the "golang" test, which I'm going to be modifying soon over to to this new convention. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 2 +- t/t4018/README | 8 +++++++ t/t4018/golang | 39 +++++++++++++++++++++++++++++++++ t/t4018/golang-complex-function | 9 -------- t/t4018/golang-func | 5 ----- t/t4018/golang-interface | 5 ----- t/t4018/golang-long-func | 6 ----- t/t4018/golang-struct | 5 ----- 8 files changed, 48 insertions(+), 31 deletions(-) create mode 100644 t/t4018/golang delete mode 100644 t/t4018/golang-complex-function delete mode 100644 t/t4018/golang-func delete mode 100644 t/t4018/golang-interface delete mode 100644 t/t4018/golang-long-func delete mode 100644 t/t4018/golang-struct diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 6fd3dce1364..7fc4291f4be 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -67,7 +67,7 @@ test_expect_success 'last regexp must not be negated' ' test_expect_success 'setup hunk header tests' ' for i in $diffpatterns do - echo "$i-* diff=$i" + echo "$i* diff=$i" done > .gitattributes && cp -R "$TEST_DIRECTORY"/t4018 . && diff --git a/t/t4018/README b/t/t4018/README index 54ae735d5f8..a3220dd6374 100644 --- a/t/t4018/README +++ b/t/t4018/README @@ -41,6 +41,9 @@ below) are: Create test cases called "LANG-whatever" in this directory, where "whatever" is a brief description of the test. +You can also stick all the tests into one "LANG" file. See "t4018 +description" below. + Any line starting with "t4018" is a control line for the test: - The "t4018 header:" line above specifies what text must appear in @@ -48,6 +51,11 @@ Any line starting with "t4018" is a control line for the test: the line for ease of not having to hardcode the line numbers and offsets. + - The "t4018 description:" line above the test is a convention to add + a human-readable description for the test. Unlike in the case of + the LANG.sh test cases these descriptions don't make it to + "test_expect_success", and won't be seen in the test output. + In many of the test cases the header line includes the token "RIGHT", this used to be part of the test syntax, but isn't anymore. Now we care about the "t4018 header:" line, not whatever line contains a diff --git a/t/t4018/golang b/t/t4018/golang new file mode 100644 index 00000000000..000e66b1c7b --- /dev/null +++ b/t/t4018/golang @@ -0,0 +1,39 @@ +t4018 description: complex function +t4018 header: func (t *Test) RIGHT(a Type) (Type, error) { +type Test struct { + a Type +} + +func (t *Test) RIGHT(a Type) (Type, error) { + t.a = a + return ChangeMe, nil +} + +t4018 description: func +t4018 header: func RIGHT() { +func RIGHT() { + a := 5 + b := ChangeMe +} + +t4018 description: interface +t4018 header: type RIGHT interface { +type RIGHT interface { + a() Type + b() ChangeMe +} + +t4018 description: long func +t4018 header: func RIGHT(aVeryVeryVeryLongVariableName AVeryVeryVeryLongType, +func RIGHT(aVeryVeryVeryLongVariableName AVeryVeryVeryLongType, + anotherLongVariableName AnotherLongType) { + a := 5 + b := ChangeMe +} + +t4018 description: struct +t4018 header: type RIGHT struct { +type RIGHT struct { + a Type + b ChangeMe +} diff --git a/t/t4018/golang-complex-function b/t/t4018/golang-complex-function deleted file mode 100644 index 0574ba912e6..00000000000 --- a/t/t4018/golang-complex-function +++ /dev/null @@ -1,9 +0,0 @@ -t4018 header: func (t *Test) RIGHT(a Type) (Type, error) { -type Test struct { - a Type -} - -func (t *Test) RIGHT(a Type) (Type, error) { - t.a = a - return ChangeMe, nil -} diff --git a/t/t4018/golang-func b/t/t4018/golang-func deleted file mode 100644 index 0472cfd9798..00000000000 --- a/t/t4018/golang-func +++ /dev/null @@ -1,5 +0,0 @@ -t4018 header: func RIGHT() { -func RIGHT() { - a := 5 - b := ChangeMe -} diff --git a/t/t4018/golang-interface b/t/t4018/golang-interface deleted file mode 100644 index 3160a1d4524..00000000000 --- a/t/t4018/golang-interface +++ /dev/null @@ -1,5 +0,0 @@ -t4018 header: type RIGHT interface { -type RIGHT interface { - a() Type - b() ChangeMe -} diff --git a/t/t4018/golang-long-func b/t/t4018/golang-long-func deleted file mode 100644 index de83aaafca5..00000000000 --- a/t/t4018/golang-long-func +++ /dev/null @@ -1,6 +0,0 @@ -t4018 header: func RIGHT(aVeryVeryVeryLongVariableName AVeryVeryVeryLongType, -func RIGHT(aVeryVeryVeryLongVariableName AVeryVeryVeryLongType, - anotherLongVariableName AnotherLongType) { - a := 5 - b := ChangeMe -} diff --git a/t/t4018/golang-struct b/t/t4018/golang-struct deleted file mode 100644 index fc8022537b2..00000000000 --- a/t/t4018/golang-struct +++ /dev/null @@ -1,5 +0,0 @@ -t4018 header: type RIGHT struct { -type RIGHT struct { - a Type - b ChangeMe -} From patchwork Wed Feb 24 19:51:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102369 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=-15.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,USER_AGENT_GIT 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 14F08C433DB for ; Wed, 24 Feb 2021 19:54:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D01F864F07 for ; Wed, 24 Feb 2021 19:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235277AbhBXTye (ORCPT ); Wed, 24 Feb 2021 14:54:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235098AbhBXTxc (ORCPT ); Wed, 24 Feb 2021 14:53:32 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91EADC06121E for ; Wed, 24 Feb 2021 11:52:07 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id n4so1468257wmq.3 for ; Wed, 24 Feb 2021 11:52:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qeCVDIPmNTCF1cRMK5wyyJqLDHKY0nCFz+Emh8bCGvM=; b=p3ewJo67kQifg3OIdTO7hTrh6ZQwLQ2ZEDLBdhwu77PwXkRHVy+hCUlXvF05Bdv2sJ RbodBVbFvt104wXKhbdJT+/LdIwpYodsLU0X+Gm5Yn0y0h9O5QJiov99COYu7JMFdjjW y+6guvs+0PLQpHhngNgB35cchg/y/K/G8p0WCQlvVAb5LPrbQJE4SIaUUzh5O/XtKsxS Gmr12+tT330RWu0RINLfIJdqKMe+YdgqQJMKz8KvCEnE0srRsGHUMjxiHhRiXaD3BeSp xSqvYAppELs9U/SPE2MAW1DXYidnnyGYyQMz/tPOnMBiP3EH7D0ie7uvP1q4JnhUiUGC G/Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qeCVDIPmNTCF1cRMK5wyyJqLDHKY0nCFz+Emh8bCGvM=; b=thqI/Y3b17Yjug+cF5k67eGY+w0qqxyTjHD+jTe6yapmjGLKG5tsSl/9nZ3dSlYrsq YSlRJTb7/Tuim9k4UAu4pJEfgWNXvcBi+OrjCp7z1eHAnRS+QL1sqcvssnzO/QCYqUd2 geN8nJc9CbkgH+D7hgpDfbQl7UVphJn1nmUPdkSzmXY09HBRPYIF8HzI4aO21HMBL348 yuZtQqY5dPv+Oj/YS9+xI2b7j0Dpbq+Pg4DWZWkJLe+0gVpsF58gNLxHPUb70prcj6cu H7ckj+TK1abLu5LJB5quRkuOung8aDhPa6IXRLQHbjQxg6FyvB4G2qsANSTL0Fh9PR0b HzDA== X-Gm-Message-State: AOAM533fYsP5fC+UGJ1njGmEQlSDpgZ+wr9HKhEEDg593nn4KvaU8AT9 a5rb81boV36HCsstOVnzugnVOVX05MKuWw== X-Google-Smtp-Source: ABdhPJzX8sJWBup6u6ofT/fCC5DDOue8AaNbFNY+GJUgKElTqY5iObYTK2OUldjOLUKOd8VhzceF6g== X-Received: by 2002:a7b:c304:: with SMTP id k4mr5140407wmj.11.1614196326071; Wed, 24 Feb 2021 11:52:06 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:05 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 16/35] userdiff tests: do config teardown in test_diff_funcname() Date: Wed, 24 Feb 2021 20:51:10 +0100 Message-Id: <20210224195129.4004-17-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Do a teardown of any custom "diff..x?funcname" config after a test_diff_funcname() test runs. Nothing currently uses this, but a follow-up commit will start setting custom config before certain tests. Centralizing this teardown makes the tests simpler. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 7fc4291f4be..496313fc900 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -123,6 +123,13 @@ test_diff_funcname () { git diff -U1 "$what" >diff && last_diff_context_line diff >actual && test_cmp expected actual + ' && + + test_expect_success "teardown: $desc" ' + # In case any custom config was set immediately before + # the test itself in the test file + test_unconfig "diff.$what.funcname" && + test_unconfig "diff.$what.xfuncname" ' } From patchwork Wed Feb 24 19:51:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102389 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=-15.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,USER_AGENT_GIT 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 5C7FDC433E0 for ; Wed, 24 Feb 2021 19:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2789F64F03 for ; Wed, 24 Feb 2021 19:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235243AbhBXT4n (ORCPT ); Wed, 24 Feb 2021 14:56:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234718AbhBXTx5 (ORCPT ); Wed, 24 Feb 2021 14:53:57 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9128AC06121F for ; Wed, 24 Feb 2021 11:52:08 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id w7so2796004wmb.5 for ; Wed, 24 Feb 2021 11:52:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hYqILTozRcLmffUhghiG81a7ez+XYfWlrKIzGlF6CoU=; b=iXDs7kR6F0/TaMk2a2lq6GoEkmRqWWCUrJHZPFt0Ty+aaDtsiGwDDPBIQJ3SSQTyO+ y/fqPI4FqKjuQ9+KcwrD63atlrUyc6y30RpY2vZdopZIrXCA7X1TV1tO8y4XOkzysHFn Bp7An9kOhecUh8KuzehQO4uM8h2QOnuVIRPq6zEEEzyAwcDsL/RMt5fqudvdmE3iqQt7 xehkJp/mY5dcSmAFhJjkjbNAJHd1UBInOmmkEbMaHSogVJiV37GqudXRnJYrvLQ/jifx TLW9qu7VzGBgkG4ljtamZ6jrNcgbGugCJleRJ17EdDCTlZdaDtMNJ4W7Lyl5T6lLNxBk +6Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hYqILTozRcLmffUhghiG81a7ez+XYfWlrKIzGlF6CoU=; b=t/3X9SirNBXRjqKyEBV5BRFhjyP5wG3z5MUuAnG9tHFGZB0zmCaWMRfGwtCykMJZY8 i2pjF6rEXPamJ7gwlV6DVNvv+agarz/jtSSvmPiXuZA0Grsa8vSgAnc3+ShVwBr5a3Eo VTNxJ/inedQiVHkE0bNZdJzsihLOzzCNZU2QcXB+nKMkJYa1ve475L89fNsbnlbi/lGb a7NnHmy0VJKuB1q+3bpqSuomekKNOBgLeEweXKaAwJQwLaksNFcH53Z3Ky34tHj4N0TV UECwlUbdITdws8FPJ1Lel6zK8pQqPptVlxBeOeXXbSYs3Fr0fAVJOSoknAeXqyeAU//j wsdA== X-Gm-Message-State: AOAM53202+g8tWaRBR4RInQg8Y4k6eLsORj4xsVuSYbVosr5tw1dotW7 nmmsyQkjf4xGH61OwwdjFYNNrQ3fmJ2AXw== X-Google-Smtp-Source: ABdhPJzLnBAcI3gC/33uAwNBQ0Rjl0dhW+ukTRzteUuzVoXrM89Epjz+nZGHLUxugk5BefNgX7sO+A== X-Received: by 2002:a05:600c:228c:: with SMTP id 12mr5140671wmf.74.1614196326954; Wed, 24 Feb 2021 11:52:06 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:06 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 17/35] userdiff tests: move custom patterns into one test file Date: Wed, 24 Feb 2021 20:51:11 +0100 Message-Id: <20210224195129.4004-18-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a preceding commit the test infrastructure got rewritten so "t/t4018/" are now normal test files which can do things like set config, so let's make it responsible for setting up and tearing down the config for its tests. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 16 +------- t/t4018/custom.sh | 79 ++++++++++++++++++++++++++++++++++++++++ t/t4018/custom1.sh | 27 -------------- t/t4018/custom2.sh | 18 --------- t/t4018/custom3.sh | 27 -------------- 5 files changed, 80 insertions(+), 87 deletions(-) create mode 100755 t/t4018/custom.sh delete mode 100755 t/t4018/custom1.sh delete mode 100755 t/t4018/custom2.sh delete mode 100755 t/t4018/custom3.sh diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 496313fc900..71a7b474cd4 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -15,18 +15,6 @@ test_expect_success 'setup' ' sort builtin-drivers.sorted && test_cmp builtin-drivers.sorted builtin-drivers && - # a non-trivial custom pattern - git config diff.custom1.funcname "!static -!String -[^ ].*s.*" && - - # a custom pattern which matches to end of line - git config diff.custom2.funcname "......Beer\$" && - - # alternation in pattern - git config diff.custom3.funcname "Beer$" && - git config diff.custom3.xfuncname "^[ ]*((public|static).*)$" && - # for regexp compilation tests echo A >A.java && echo B >B.java @@ -34,9 +22,7 @@ test_expect_success 'setup' ' diffpatterns=" $(cat builtin-drivers) - custom1 - custom2 - custom3 + custom " for p in $diffpatterns diff --git a/t/t4018/custom.sh b/t/t4018/custom.sh new file mode 100755 index 00000000000..59d855c01c5 --- /dev/null +++ b/t/t4018/custom.sh @@ -0,0 +1,79 @@ +#!/bin/sh +# +# See ../t4018-diff-funcname.sh's test_diff_funcname() +# + +test_expect_success 'custom: setup non-trivial custom' ' + git config diff.custom.funcname "!static +!String +[^ ].*s.*" +' + +test_diff_funcname 'custom: non-trivial custom pattern' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +int special, RIGHT; +EOF_HUNK +public class Beer +{ + int special, RIGHT; + public static void main(String args[]) + { + String s=" "; + for(int x = 99; x > 0; x--) + { + System.out.print(x + " bottles of beer on the wall " + + x + " bottles of beer\n" // ChangeMe + + "Take one down, pass it around, " + (x - 1) + + " bottles of beer on the wall.\n"); + } + System.out.print("Go to the store, buy some more,\n" + + "99 bottles of beer on the wall.\n"); + } +} +EOF_TEST + +test_expect_success 'custom: setup match to end of line' ' + git config diff.custom.funcname "......Beer\$" +' + +test_diff_funcname 'custom: match to end of line' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +RIGHT_Beer +EOF_HUNK +public class RIGHT_Beer +{ + int special; + public static void main(String args[]) + { + System.out.print("ChangeMe"); + } +} +EOF_TEST + +test_expect_success 'custom: setup alternation in pattern' ' + git config diff.custom.funcname "Beer$" && + git config diff.custom.xfuncname "^[ ]*((public|static).*)$" +' + +test_diff_funcname 'custom: alternation in pattern' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +public static void main(String RIGHT[]) +EOF_HUNK +public class Beer +{ + int special; + public static void main(String RIGHT[]) + { + String s=" "; + for(int x = 99; x > 0; x--) + { + System.out.print(x + " bottles of beer on the wall " + + x + " bottles of beer\n" // ChangeMe + + "Take one down, pass it around, " + (x - 1) + + " bottles of beer on the wall.\n"); + } + System.out.print("Go to the store, buy some more,\n" + + "99 bottles of beer on the wall.\n"); + } +} +EOF_TEST diff --git a/t/t4018/custom1.sh b/t/t4018/custom1.sh deleted file mode 100755 index f8bbccadb47..00000000000 --- a/t/t4018/custom1.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# -# See ../t4018-diff-funcname.sh's test_diff_funcname() -# - -test_diff_funcname 'custom1: pattern' \ - 8<<\EOF_HUNK 9<<\EOF_TEST -int special, RIGHT; -EOF_HUNK -public class Beer -{ - int special, RIGHT; - public static void main(String args[]) - { - String s=" "; - for(int x = 99; x > 0; x--) - { - System.out.print(x + " bottles of beer on the wall " - + x + " bottles of beer\n" // ChangeMe - + "Take one down, pass it around, " + (x - 1) - + " bottles of beer on the wall.\n"); - } - System.out.print("Go to the store, buy some more,\n" - + "99 bottles of beer on the wall.\n"); - } -} -EOF_TEST diff --git a/t/t4018/custom2.sh b/t/t4018/custom2.sh deleted file mode 100755 index c68421f788e..00000000000 --- a/t/t4018/custom2.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# -# See ../t4018-diff-funcname.sh's test_diff_funcname() -# - -test_diff_funcname 'custom2: match to end of line' \ - 8<<\EOF_HUNK 9<<\EOF_TEST -RIGHT_Beer -EOF_HUNK -public class RIGHT_Beer -{ - int special; - public static void main(String args[]) - { - System.out.print("ChangeMe"); - } -} -EOF_TEST diff --git a/t/t4018/custom3.sh b/t/t4018/custom3.sh deleted file mode 100755 index 07c5c134ffe..00000000000 --- a/t/t4018/custom3.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# -# See ../t4018-diff-funcname.sh's test_diff_funcname() -# - -test_diff_funcname 'custom3: alternation in pattern' \ - 8<<\EOF_HUNK 9<<\EOF_TEST -public static void main(String RIGHT[]) -EOF_HUNK -public class Beer -{ - int special; - public static void main(String RIGHT[]) - { - String s=" "; - for(int x = 99; x > 0; x--) - { - System.out.print(x + " bottles of beer on the wall " - + x + " bottles of beer\n" // ChangeMe - + "Take one down, pass it around, " + (x - 1) - + " bottles of beer on the wall.\n"); - } - System.out.print("Go to the store, buy some more,\n" - + "99 bottles of beer on the wall.\n"); - } -} -EOF_TEST From patchwork Wed Feb 24 19:51:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102391 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=-15.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,USER_AGENT_GIT 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 A0600C433DB for ; Wed, 24 Feb 2021 19:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5611964F06 for ; Wed, 24 Feb 2021 19:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235366AbhBXT4z (ORCPT ); Wed, 24 Feb 2021 14:56:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234738AbhBXTx5 (ORCPT ); Wed, 24 Feb 2021 14:53:57 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D8BC061221 for ; Wed, 24 Feb 2021 11:52:09 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id d11so3037821wrj.7 for ; Wed, 24 Feb 2021 11:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6qmS9PrfdhIeIeFeP3x40mGKAshC9wGUO7SYkvYbIEk=; b=XeqF8G6Bruv7YnqaG1CcVGnS4Q6+jtXWPhwfYoM61Qo+/CsaTf6Fn2Fys7L4v+6U+q pdxu7xI6yaYuzTsosd0To2PLeal9X76USsnxPSvf2ty/F5H0zjGpRlXY7Wq2grHzNUCP FYY7NalLuMZIShcIh6D9UIg1m+Ox7Jq+OCgrHhR0oROCQTb1YFgezMsETACRhr1oSeJy S+1a8Pskz1LlLia03AORATg3EYN/p3+itZxXiTWzpxxvD/kZTrwGLEPhNmXMEMIjuKML tILdlbxTFqth3+NmxzDf2xaZ1PG7IB6DpSvVQkLw2e35y0IxUxPHuT6z//Y7qT0rG+hk w8QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6qmS9PrfdhIeIeFeP3x40mGKAshC9wGUO7SYkvYbIEk=; b=mZ6yE8BoIf+WM7NKDUpxoDEWu7QUAGuSNdKxHg35N3JBXQ7ccrgpPBsev7Ake6gtn2 yAOtml7YyMDHOh4+CaSpVQboqLPJvfT+Frss7AkFexTLkTkyhAjUx9+EZek4Oo4dDh9P M4reZtivpqGxKjdgi213pC8745radbCxHQcIgRMMjFXSZrJtrpuKcTkQUq9x22dhtEb6 jyxE8zJY2Orjb/rairYSFjHrbUkJ/ynrR2fZze+mrHQrOvBao3JYiNqWSH5rX4/lglWj WvltVIlCELHomYHIkTtVhHHOy5dZgcsTBHxCi28zjGxQ99AkteuPxVwFwUE9kx0jbTeG Mgtg== X-Gm-Message-State: AOAM531oLth0ei66rhgN9HGD6IbDADwGTrppB3Br8i5YgeZbM6jo0YiK P9Dw4zkMlbG3LdDpVAbmHuW8KzV62S8faw== X-Google-Smtp-Source: ABdhPJxwImwfjJ+3Z4eqKCMBJB45Tc61Thwg6ubu32YdxGkhOZi+xolJOTLxhkKhfN3j22liSd0l0g== X-Received: by 2002:adf:f211:: with SMTP id p17mr24377133wro.346.1614196327815; Wed, 24 Feb 2021 11:52:07 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:07 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 18/35] userdiff tests: remove hack for "RIGHT" token Date: Wed, 24 Feb 2021 20:51:12 +0100 Message-Id: <20210224195129.4004-19-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that the "RIGHT" token isn't how we select the desired hunk header line in the test anymore we can revert a hack added in f1b75fbaf1 (t4018: convert custom pattern test to the new infrastructure, 2014-03-21) and go back to the regular expression we were testing before that change. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/custom.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t4018/custom.sh b/t/t4018/custom.sh index 59d855c01c5..b208a771d28 100755 --- a/t/t4018/custom.sh +++ b/t/t4018/custom.sh @@ -33,14 +33,14 @@ public class Beer EOF_TEST test_expect_success 'custom: setup match to end of line' ' - git config diff.custom.funcname "......Beer\$" + git config diff.custom.funcname "Beer\$" ' test_diff_funcname 'custom: match to end of line' \ 8<<\EOF_HUNK 9<<\EOF_TEST -RIGHT_Beer +Beer EOF_HUNK -public class RIGHT_Beer +public class Beer { int special; public static void main(String args[]) From patchwork Wed Feb 24 19:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102373 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=-15.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,USER_AGENT_GIT 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 B77B2C433DB for ; Wed, 24 Feb 2021 19:54:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68DA864EF5 for ; Wed, 24 Feb 2021 19:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235292AbhBXTyl (ORCPT ); Wed, 24 Feb 2021 14:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235116AbhBXTxe (ORCPT ); Wed, 24 Feb 2021 14:53:34 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67223C061222 for ; Wed, 24 Feb 2021 11:52:10 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id p3so2804372wmc.2 for ; Wed, 24 Feb 2021 11:52:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5FN0keZbyeJBed2PZ2BnHxfrCE+eaOJxl4AOhzI+t4E=; b=Ko1HoW77RN1d+WPXxLqI4jVKzxvRlNZPF92hwg2yJt8cBFB394LSZswvaAi4MNSNbf /mBhaeK9Of1Q/WO4lSTbRwZLgWSjmwqYg5OWZvTkFaI2vVcGaEhtKEmq2U8o+PInjsb2 p94ftDHkicsmWSlV09NFA6zeNEUsFniVdw0BzIkB2zbKQSlvH2KnT3tMGkUyjQUVAcJO 16+4iZJ1rp93QDzM6n5QbveLXMRDXL5nF1eBFrp7tXnMz4BkApEcokWAJcZS3EARh+0P dEc10YLikJi7vpHoZBFWcTNHB05QjjwhtT+pHkUAhAEZoG9ehUnfHWg7jCbjqBW5JMOH pwdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5FN0keZbyeJBed2PZ2BnHxfrCE+eaOJxl4AOhzI+t4E=; b=lCR14Y/blVYJAs3UX+ojuPEwgW6enwZ90fkE+BT5UiQ7bFe3/0lTPtUDiM0Orz5bVP zDQfPQSjE5eFrEY8qhS0aR16XeKCXaizseNuVIaqr7Jmfpmq6WGUxZiCrJlkiggqatxO 4XuoVyxdbW0AGJusJz6gvWTACZIXP5IsIbBuoMjc34fto21oiUaxwMpdGDuUISu9Y+4D xJTpH+5bXSI8h459SV8UqqzP899dxAamIoTSKx9/NBwYcb64MpPPvwtwTTFheUPC9RiQ y4Uk9SW8CQqekLUXzX/24JKnCL/u7N83VAEhIamEpKH+HvbgVQXpkGyWti0g/2nfwu40 fAFA== X-Gm-Message-State: AOAM5309zS/5Hv3nIR5JmXanF3QVwSjAICEFrURMjOzHnUPMPoy84OZW lWxfYQDuhqWls1nu/9K7jdghAvsOLq2kmw== X-Google-Smtp-Source: ABdhPJxDzCKTl+jdXQCBiUmVBxF3aiTPw/EoX/8iMi2e+AwQjIU4ioJzjOg8akGlVLELU9r8xkvlcA== X-Received: by 2002:a1c:d7:: with SMTP id 206mr5247667wma.68.1614196328905; Wed, 24 Feb 2021 11:52:08 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:08 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 19/35] userdiff tests: do not do compile tests on "custom" pattern Date: Wed, 24 Feb 2021 20:51:13 +0100 Message-Id: <20210224195129.4004-20-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since f1b75fbaf1 (t4018: convert custom pattern test to the new infrastructure, 2014-03-21) we have been doing the basic sanity check of whether patterns in userdiff.c compile on the "custom" patterns. That we were doing this was an emergent effect of that change and an earlier refactoring in bfa7d01413 (t4018: an infrastructure to test hunk headers, 2014-03-21). This was never intended by the test added in e3bf5e43fd (t4018-diff-funcname: test syntax of builtin xfuncname patterns, 2008-09-22), nor is there any point in doing this. We'll error out in the custom.sh test itself if those patterns don't compile. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 71a7b474cd4..b80546b4d7f 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -20,12 +20,7 @@ test_expect_success 'setup' ' echo B >B.java ' -diffpatterns=" - $(cat builtin-drivers) - custom -" - -for p in $diffpatterns +for p in $(cat builtin-drivers) do test_expect_success "builtin $p pattern compiles" ' echo "*.java diff=$p" >.gitattributes && @@ -50,6 +45,11 @@ test_expect_success 'last regexp must not be negated' ' test_i18ngrep ": Last expression must not be negated:" msg ' +diffpatterns=" + $(cat builtin-drivers) + custom +" + test_expect_success 'setup hunk header tests' ' for i in $diffpatterns do From patchwork Wed Feb 24 19:51:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102395 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=-15.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,USER_AGENT_GIT 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 75D43C433E0 for ; Wed, 24 Feb 2021 19:57:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DAB564F06 for ; Wed, 24 Feb 2021 19:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234644AbhBXT5T (ORCPT ); Wed, 24 Feb 2021 14:57:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234761AbhBXTx7 (ORCPT ); Wed, 24 Feb 2021 14:53:59 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFE9C061223 for ; Wed, 24 Feb 2021 11:52:11 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id h98so3027962wrh.11 for ; Wed, 24 Feb 2021 11:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+gGJSV4KxLtrBBgeCEs4RL+dZPUAVeroChKdibGZHPc=; b=Y9Pvsdz1JS2pJOJZVen5IeI0g4lqgDqPCzt+df6EMqRmWblRgXJE95QXvDozQl1ON4 PENZC96o+iy8kQAm6CCUhp4zrQlVsdnJU67u6V1tDjgDebfSXUEOb4PDJWP6ts8ssZF9 Mg9Gvzk5u56xkozoYdbmnnFRvLTphtWqjDVRf9x3YMIvm5mgax9+PfttSDvdBSp2fpFw JEg590E6qc6S+XDdsHwEoCknQAKVIz9A+gfQuRFED9WLBJe89s3VDDqe14MXk33vma3g aALlw0L+knU5KAUYg4LoV6WZ9dxYGXlKNNhWt/5fgiCIVZyYCDt4nxvxO4qzVELynS6H 3V3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+gGJSV4KxLtrBBgeCEs4RL+dZPUAVeroChKdibGZHPc=; b=MEQCtcEMJEB9/NzrmUOqxyg2SNP0NkLQqe7pb5cGgTIHoiZmS242FwrgDBxXAOmiud fSTaXzphcAtjXdV/nqTWK4QMcB8Ruqf+cZyWgFqOHJneDzan7ipyUERfTJp3nv5eKRAO 0rq2EMgj2HxNGZPmvxPWbqJ4OuNxsKNZvWGIGrQRHm+7nvtlyK3Ku+4a2yFq9RsD5eCF fCFkfT/Ths8LRdDd8WyEn/TLsHJJpIWhp2lVtwh4aiMhYdd00TPQb1HCCa2wIClE6M5H pcHTO92j85DG3Xsn36I2x9/amiQyWWcSTIFK2qoaKdFfZfmJ0XosakJ8+KkgtcT5r+9S FBPQ== X-Gm-Message-State: AOAM530rvogACf/MnHAFSMFU4gIM/BVI7PdfwtGNoFFOrrKfVQueUSUR PbO2qBI1b4Qq2CUHziM54IgtJjwNLaY/4g== X-Google-Smtp-Source: ABdhPJyQrO7Kid1bpX8K7h0BU5IFJXyeEdpk1Qni/h8J4tqzcrRoDbsf/6dxCaMSRSdBpMcbmTVYmw== X-Received: by 2002:adf:f70a:: with SMTP id r10mr20824847wrp.61.1614196329686; Wed, 24 Feb 2021 11:52:09 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:09 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 20/35] userdiff tests: assert that new built-in drivers have tests Date: Wed, 24 Feb 2021 20:51:14 +0100 Message-Id: <20210224195129.4004-21-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add an assertion to the userdiff test framework to check that everything except a narrow whitelist of existing built-in patterns has tests. Since this test framework was added we've added new patterns without any tests. Let's make it obvious in the future in the diff for such patches that they should have those tests. For anything with tests we can skip the "does the pattern compile?" test, as the actual tests will check that for us. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index b80546b4d7f..a3058fda130 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -15,6 +15,19 @@ test_expect_success 'setup' ' sort builtin-drivers.sorted && test_cmp builtin-drivers.sorted builtin-drivers && + # Do not add anything to this list. New built-in drivers should have + # tests + cat >drivers-no-tests <<-\EOF && + ada + bibtex + csharp + html + objc + pascal + ruby + tex + EOF + # for regexp compilation tests echo A >A.java && echo B >B.java @@ -22,7 +35,12 @@ test_expect_success 'setup' ' for p in $(cat builtin-drivers) do - test_expect_success "builtin $p pattern compiles" ' + P=$(echo $p | tr 'a-z' 'A-Z') + if grep -q $p drivers-no-tests + then + test_set_prereq NO_TEST_FOR_DRIVER_$P + fi + test_expect_success NO_TEST_FOR_DRIVER_$P "builtin $p pattern compiles" ' echo "*.java diff=$p" >.gitattributes && test_expect_code 1 git diff --no-index \ A.java B.java 2>msg && @@ -119,11 +137,17 @@ test_diff_funcname () { ' } +>drivers-had-no-tests for what in $diffpatterns do test="$TEST_DIRECTORY/t4018/$what.sh" if ! test -e "$test" then + git -C t4018 ls-files ':!*.sh' "$what*" >other-tests && + if ! test -s other-tests + then + echo $what >>drivers-had-no-tests + fi continue fi && @@ -135,4 +159,8 @@ do . "$test" done +test_expect_success 'we should not have new built-in drivers without tests' ' + test_cmp drivers-no-tests drivers-had-no-tests +' + test_done From patchwork Wed Feb 24 19:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102375 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=-15.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,USER_AGENT_GIT 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 42C6EC433DB for ; Wed, 24 Feb 2021 19:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1AE664EF5 for ; Wed, 24 Feb 2021 19:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235306AbhBXTy5 (ORCPT ); Wed, 24 Feb 2021 14:54:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235120AbhBXTxf (ORCPT ); Wed, 24 Feb 2021 14:53:35 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0719FC061224 for ; Wed, 24 Feb 2021 11:52:12 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id k66so2911160wmf.1 for ; Wed, 24 Feb 2021 11:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qtJyhjN+eqrcJS5xBh7kjYEQfMWHO6hi9ZXIw2F5v3E=; b=XACqqRBSyMwrxAmuBOA1BEPw0CthKRb70FPh9QUT1Bjih9OrBnYsh1FjSXfa52j3+z TkjxM9BMNjCv0y2MWUoqyr++HM0wR7EFcMmERuxFSAd2Kb4sgET+dI3MmMsdY5QVBfU/ 7aKjzb+9q45eBG6sGi6O06Ef2UgPZbHUg+1gIzJ7N2XPmibvVwRxiYQ4KJSJxBtQ8aPm DZFGYfwm7WBUeAg06taXlZIWAZWGrSoJdgLCl0DmbUL3mLJVp95EP2BGMul/yE/9xCkp fQaSzU4ohOCVYzc2kLs0guRbdC+MKOBw/PMizFh1drFV5VuFtvhuNQP8sSzORyZCmdQ7 ru2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qtJyhjN+eqrcJS5xBh7kjYEQfMWHO6hi9ZXIw2F5v3E=; b=cUGWA6lN7RrKy78xRTuwT/1CZTE3Q6xLutFM6hZLP3MvUy8RE7+MEpaiiVPdcyxzT1 JR/B5aREx+RB/JzXyxEMfRhCKfk+pXwcJj8c6z6HQPLjC25r4WAIq6rKq6NhppFZVTgS 2axW+6pJZiwaAsT7EMEEssvGQcV2KtCL8jtIhOo4O/svaDsW10QJX8gRJ8Ph4fc5lwka 0BUM7ruPAQYHByl5Zsi97oWv5BWT2S8BwzhSCh5K/wKAOEwfPZaXmGaSlEQbaljlSQT/ QtrQBOnDlBQr5pot38rODOu9fhYv1gsHUCkFYOZPsc7o1lrQomTaqgju8doGSj8Dqn5J zL2A== X-Gm-Message-State: AOAM532g4wmR5rEJDxdeNgntV9rj5uUcOLc/x5U3G6mZ/7+lLyydeOT2 6HOzlsosoO1IBfjF0FkeWWniuaOQVD4e1Q== X-Google-Smtp-Source: ABdhPJzmfAr4pKKOBlBB37hG+/egJCN1W/Obx9Po4VuhojhI+0oZRE1PKzqZo6NB+1I9UrIq7ug/Pw== X-Received: by 2002:a1c:41c3:: with SMTP id o186mr5200722wma.7.1614196330525; Wed, 24 Feb 2021 11:52:10 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:09 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 21/35] userdiff tests + docs: document & test "diff..x?funcname" Date: Wed, 24 Feb 2021 20:51:15 +0100 Message-Id: <20210224195129.4004-22-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add the missing documentation for "diff..funcname" and test for how it and "diff..xfuncname" interact. Between the introduction of the "diff..xfuncname" form in 45d9414fa5 (diff.*.xfuncname which uses "extended" regex's for hunk header selection, 2008-09-18) and when this documentation was written in 90b94c26f7 (Documentation: Add diff..* to config, 2011-04-07) we forgot to document the existence of "diff..funcname". Let's make a mention of it here, we could also partially revert the former commit and discuss the more verbose form in gitattributes(5), but let's stop short of that. It makes sense to guide users towards ERE over BRE whenever possible. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config/diff.txt | 11 +++++++++++ t/t4018/custom.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt index 2d3331f55c2..6f39ef1da93 100644 --- a/Documentation/config/diff.txt +++ b/Documentation/config/diff.txt @@ -153,10 +153,21 @@ diff..command:: The custom diff driver command. See linkgit:gitattributes[5] for details. +diff..funcname:: diff..xfuncname:: The regular expression that the diff driver should use to recognize the hunk header. A built-in pattern may also be used. See linkgit:gitattributes[5] for details. ++ +When provided as `diff..funcname` the regular expression is +interpreted as a basic regular expression. With +`diff..xfuncname` it's interpreted as an extended regular +expression. ++ +The `*.funcname` and `*.xfuncname` variables behave as if though they +were one configuration variable for the purposes of what value +eventually gets used. Setting `*.funcname` will override an earlier +`*.xfuncname` and vice-versa. diff..binary:: Set this option to true to make the diff driver treat files as diff --git a/t/t4018/custom.sh b/t/t4018/custom.sh index b208a771d28..72d38dad686 100755 --- a/t/t4018/custom.sh +++ b/t/t4018/custom.sh @@ -77,3 +77,37 @@ public class Beer } } EOF_TEST + +test_expect_success 'custom: setup config precedence' ' + git config diff.custom.funcname "foo" && + git config diff.custom.xfuncname "bar" +' + +test_diff_funcname 'custom: config precedence' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +bar +EOF_HUNK +foo +bar + +ChangeMe + +baz +EOF_TEST + +test_expect_success 'custom: setup config precedence' ' + git config diff.custom.xfuncname "bar" && + git config diff.custom.funcname "foo" +' + +test_diff_funcname 'custom: config precedence' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +foo +EOF_HUNK +foo +bar + +ChangeMe + +baz +EOF_TEST From patchwork Wed Feb 24 19:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102393 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=-15.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,USER_AGENT_GIT 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 C71A5C433DB for ; Wed, 24 Feb 2021 19:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88F3964EDD for ; Wed, 24 Feb 2021 19:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235299AbhBXT5F (ORCPT ); Wed, 24 Feb 2021 14:57:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235195AbhBXTyA (ORCPT ); Wed, 24 Feb 2021 14:54:00 -0500 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 C9A8BC061225 for ; Wed, 24 Feb 2021 11:52:12 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id v15so3049795wrx.4 for ; Wed, 24 Feb 2021 11:52:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xMxsQH8TvqCF23zGXJVMeFs/8y2sLDsvMR6mtJLBjfI=; b=AV0QIYWmUy21ltuRjtZ2C1PgMFW1pS37LazAJSNegbherIEkyOgMgTkWFEmwfwF1+q k6v48rVvjNto2iw33PnFk6lHZGBrk8fnuWvbm3T02hJk908bQhBUEiMAcBzTjO44fErv TXHDfb7+VI2zfBtOShFwANRhW5WiNOWccqESjLOLQS/HRPu6uiQwMqAP6ULeSmaieXj4 e3xbAjWVac1O732WrL+XHVImcggLUsz3iYReJf3AXmyW2y5CHAYLrHVWun1i5F5z1lsN qVUDf4wM73GEgG+ru3S3HqrepQaPWBENd1hk7MbI14KbENkPisaX7J9QSJ7dp9adekMH rVqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xMxsQH8TvqCF23zGXJVMeFs/8y2sLDsvMR6mtJLBjfI=; b=bGGdBZv6LHkEIV+gJOQfQXHA7SuNOJmOEJhYzattdbUy1oHwcj0lvzHYG1b88IgqbC tKbDBssBnva/1mKibSEkePirtASOPYxOIxKyYlSNhTroqeXh9JZeOqFvDGfKZ05K+/I0 0vlNmPEUl2RHcosxIEVg3202GJ8QKwTXS5a8P2q8J0Pjo7dpc58Ld+fPwLEWpF2Wqv6H 3OF5JWrKVAQtAc/C1n0r6ukEQKpuVRVsXc/euAuwxu8zvTpXTPRIFih1goJeYqyDo79r NS+UR35g4XBAV87+yl5qslmST+/7NNnc6ErEtBp+FifNHaeVckOAHHfJvPPU/J8RYAj+ 23kw== X-Gm-Message-State: AOAM531GADgZBCOAw+MIPfE3Cg1w1VGgckqRTgIckwdUvbUVq0/PhA03 Y5zifejKaudUrJmqUjxwjYRtuw3pR5n7ug== X-Google-Smtp-Source: ABdhPJyNVwIPcMO5fC3+h2ods2Jfb19lZ7D27r4PmCEP2gCtzVu2gPN4j93+5/QoC5u/pz7gmY0qQw== X-Received: by 2002:a5d:4c82:: with SMTP id z2mr32896929wrs.220.1614196331261; Wed, 24 Feb 2021 11:52:11 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:10 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 22/35] gitattributes doc: reword discussion of built-in userdiff patterns Date: Wed, 24 Feb 2021 20:51:16 +0100 Message-Id: <20210224195129.4004-23-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Reword the discussion of the built-in userdiff patterns to make it more natural to precede it with a discussion about the semantics of pattern matching, instead of assuming that it follows right after the "diff.tex.xfuncname" example which now immediately precedes it. This will make a follow-up commit smaller. Helped-by: Eric Sunshine Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/gitattributes.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index e84e104f932..62c1147ba97 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -794,11 +794,17 @@ backslashes; the pattern above picks a line that begins with a backslash, and zero or more occurrences of `sub` followed by `section` followed by open brace, to the end of line. -There are a few built-in patterns to make this easier, and `tex` -is one of them, so you do not have to write the above in your -configuration file (you still need to enable this with the -attribute mechanism, via `.gitattributes`). The following built in -patterns are available: +There are built-in patterns shipped as part of git itself. A more +advanced version of the `tex` pattern discussed above is one of them. + +For built-in patterns, you do not need `diff..xfuncname` in your +configuration file as discussed above, but if present, it will +override a built-in pattern. + +Nevertheless, you need to enable built-in patterns via .gitattributes` +for the pattern to take effect. + +The following built-in patterns are available: - `ada` suitable for source code in the Ada language. From patchwork Wed Feb 24 19:51:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102379 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=-15.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,USER_AGENT_GIT 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 26FE1C433DB for ; Wed, 24 Feb 2021 19:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2FBA64EF5 for ; Wed, 24 Feb 2021 19:55:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234905AbhBXTzQ (ORCPT ); Wed, 24 Feb 2021 14:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235152AbhBXTxh (ORCPT ); Wed, 24 Feb 2021 14:53:37 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD31C061226 for ; Wed, 24 Feb 2021 11:52:13 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id o10so3829997wmc.1 for ; Wed, 24 Feb 2021 11:52:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iOHeC36R0bYcnqbQ4THhJ9b9TW0bqHNxo+M2RQEpjQY=; b=ovV5hHgvapSWPpWX8oFsOeH+5I34soz0lOKdRbPXSJiR6T9R+57bsXq5PEuaNa41t+ 648AZjmff2eqSJeGencqWB/wK7VkmhI1hgPktAs2AkGkIu1WpsYxtDvW7tsdXp6CEgUU cTt/YuC5S33Xc6G0UJcN45bANngSnsoYR7/KUHSifwgXGdP/CPgLqgqqdRLdJqT1SzVU H+/gNIrpk67eBg5Hv9MCeNhFcGzvS+Xr1ejKwseP+UtlBEQ7GHZYoUcOHZAAQ/YCt+Jk fdORAof1cbCaUz//uimaS9SMGVug6q2FHYPt7tRbEzmgsOv883mdxCRxvdhXIF1FEr/A IcOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iOHeC36R0bYcnqbQ4THhJ9b9TW0bqHNxo+M2RQEpjQY=; b=NZkkmXCJv/aUJChsIkUGJM3roWpsPBDVb50r2lWNXhr4eYgtZXG1+w6qJWBjDErCyC zbHARUNFTCEONLRCdEC/1sZhc3jI9dCDlPDD4pPtu6/r6y+r30k0A4XQmn5J8KNlgMWz 11gAVOqrDrHNp6Hi5y802TawMStcs0Wlimtqk00teNAlzXyB/vr4541m6eM9Ad/08IzO 7EhtIxXgj1xAXZp0VThcSRcw472QvMj4KJtAKF3oFA+2t2fW2CM0pN7mNt/4gtwhFZyu ooFMsAc8qXAWvVDa8RmXvc5qG0m1Gp9XOt/gOwMhIxhSr5AGNGvipk0lcWqwLNqBDOvy PBWA== X-Gm-Message-State: AOAM533T3kvLCdIfg2ub8M1o+F9cufqrj+YF3p3euTGzUH+ERBvYzdhR z3cgaB9zUT06UQYRjuJdcfWmkXTc5pD+Fg== X-Google-Smtp-Source: ABdhPJxRJBDJQoK/RHaU2QEG79DSdVcOfXU5otFdBlpOn7nyHg92C45DTYDSWxXsYqs3ugebYhNGUQ== X-Received: by 2002:a05:600c:2298:: with SMTP id 24mr5329795wmf.136.1614196332152; Wed, 24 Feb 2021 11:52:12 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:11 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 23/35] userdiff tests: move perl tests to perl.sh Date: Wed, 24 Feb 2021 20:51:17 +0100 Message-Id: <20210224195129.4004-24-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the perl tests to perl.sh, a follow-up change will piggy-back on these tests for updating the userdiff documentation. This will require the new test *.sh test framework. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/perl-skip-end-of-heredoc | 9 ---- t/t4018/perl-skip-forward-decl | 11 ---- t/t4018/perl-skip-sub-in-pod | 19 ------- t/t4018/perl-sub-definition | 5 -- t/t4018/perl-sub-definition-kr-brace | 5 -- t/t4018/perl.sh | 78 ++++++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 49 deletions(-) delete mode 100644 t/t4018/perl-skip-end-of-heredoc delete mode 100644 t/t4018/perl-skip-forward-decl delete mode 100644 t/t4018/perl-skip-sub-in-pod delete mode 100644 t/t4018/perl-sub-definition delete mode 100644 t/t4018/perl-sub-definition-kr-brace create mode 100755 t/t4018/perl.sh diff --git a/t/t4018/perl-skip-end-of-heredoc b/t/t4018/perl-skip-end-of-heredoc deleted file mode 100644 index 8f90cca7314..00000000000 --- a/t/t4018/perl-skip-end-of-heredoc +++ /dev/null @@ -1,9 +0,0 @@ -t4018 header: sub RIGHTwithheredocument { -sub RIGHTwithheredocument { - print <<"EOF" -decoy here-doc -EOF - # some lines of context - # to pad it out - print "ChangeMe\n"; -} diff --git a/t/t4018/perl-skip-forward-decl b/t/t4018/perl-skip-forward-decl deleted file mode 100644 index ff1f6d14735..00000000000 --- a/t/t4018/perl-skip-forward-decl +++ /dev/null @@ -1,11 +0,0 @@ -t4018 header: package RIGHT; -package RIGHT; - -use strict; -use warnings; -use parent qw(Exporter); -our @EXPORT_OK = qw(round finalround); - -sub other; # forward declaration - -# ChangeMe diff --git a/t/t4018/perl-skip-sub-in-pod b/t/t4018/perl-skip-sub-in-pod deleted file mode 100644 index ff1c65b28fc..00000000000 --- a/t/t4018/perl-skip-sub-in-pod +++ /dev/null @@ -1,19 +0,0 @@ -t4018 header: =head1 SYNOPSIS_RIGHT -=head1 NAME - -Beer - subroutine to output fragment of a drinking song - -=head1 SYNOPSIS_RIGHT - - use Beer qw(round finalround); - - sub song { - for (my $i = 99; $i > 0; $i--) { - round $i; - } - finalround; - } - - ChangeMe; - -=cut diff --git a/t/t4018/perl-sub-definition b/t/t4018/perl-sub-definition deleted file mode 100644 index 22e16ad5363..00000000000 --- a/t/t4018/perl-sub-definition +++ /dev/null @@ -1,5 +0,0 @@ -t4018 header: sub RIGHT { -sub RIGHT { - my ($n) = @_; - print "ChangeMe"; -} diff --git a/t/t4018/perl-sub-definition-kr-brace b/t/t4018/perl-sub-definition-kr-brace deleted file mode 100644 index 6c94e6a62dd..00000000000 --- a/t/t4018/perl-sub-definition-kr-brace +++ /dev/null @@ -1,5 +0,0 @@ -t4018 header: sub RIGHT -sub RIGHT -{ - print "ChangeMe\n"; -} diff --git a/t/t4018/perl.sh b/t/t4018/perl.sh new file mode 100755 index 00000000000..ac8fff7417a --- /dev/null +++ b/t/t4018/perl.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# +# See ../t4018-diff-funcname.sh's test_diff_funcname() +# + +test_diff_funcname 'perl: skip end of heredoc' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +sub RIGHTwithheredocument { +EOF_HUNK +sub RIGHTwithheredocument { + print <<"EOF" +decoy here-doc +EOF + # some lines of context + # to pad it out + print "ChangeMe\n"; +} +EOF_TEST + +test_diff_funcname 'perl: skip forward decl' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +package RIGHT; +EOF_HUNK +package RIGHT; + +use strict; +use warnings; +use parent qw(Exporter); +our @EXPORT_OK = qw(round finalround); + +sub other; # forward declaration + +# ChangeMe +EOF_TEST + +test_diff_funcname 'perl: skip sub in pod' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +=head1 SYNOPSIS_RIGHT +EOF_HUNK +=head1 NAME + +Beer - subroutine to output fragment of a drinking song + +=head1 SYNOPSIS_RIGHT + + use Beer qw(round finalround); + + sub song { + for (my $i = 99; $i > 0; $i--) { + round $i; + } + finalround; + } + + ChangeMe; + +=cut +EOF_TEST + +test_diff_funcname 'perl: sub definition' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +sub RIGHT { +EOF_HUNK +sub RIGHT { + my ($n) = @_; + print "ChangeMe"; +} +EOF_TEST + +test_diff_funcname 'perl: sub definition kr brace' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +sub RIGHT +EOF_HUNK +sub RIGHT +{ + print "ChangeMe\n"; +} +EOF_TEST From patchwork Wed Feb 24 19:51:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102399 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=-15.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,USER_AGENT_GIT 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 5618CC433E0 for ; Wed, 24 Feb 2021 19:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C2D864F06 for ; Wed, 24 Feb 2021 19:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233889AbhBXT5f (ORCPT ); Wed, 24 Feb 2021 14:57:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234632AbhBXTyC (ORCPT ); Wed, 24 Feb 2021 14:54:02 -0500 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 80444C0611C0 for ; Wed, 24 Feb 2021 11:52:14 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id t15so3022759wrx.13 for ; Wed, 24 Feb 2021 11:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jg49T9UTxeIztOS1FaIL5Iu5Ob9FEZiMVmJUv2/c818=; b=Fgj0k2PCFT2A5khmOWTqW3AWbjyM99JQVRbLpa40lsWdc6Rc/fcjJOuykfX9jQXmWN O6/L6R0ACM1/yxaTC+R6GqZ60+N9z7DJrAJ/MVzDB3L9X9BGxS1uca3tSdFV7yw4851Y nsUlaNSUUtV4wTv9aywBoya/3HFahnT+NEQ7E6u6pl3pyo6BB/on9inVR3MxJj0V534J DoYrFhN2QqvoBolBkBkYC0ln+lGECPYVCryn8YF5cwQX0NQ/2ND3LCH3dI9YYpfZ6rTV OZoIlbEXnPmZd2CRji3SsrYz3f+2WBw8ZWyF55CM/fUv5AqXmL2q/I1C29xJMkIdqN8F 5/fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jg49T9UTxeIztOS1FaIL5Iu5Ob9FEZiMVmJUv2/c818=; b=L0K50U8Q4pVlCZKkKcUPx+WnODWVxRWEpi4Uv2CRczE5d61znOGvUc2Gg/qhduSkkc GsA4wt307eiTHjT/8BSWbgAjbgTX41tOXj/3yqZdtYK7zdT11/apIClpSMl/eFDZkZ7c sZS4sVdKT9e50FPD3cpSAfV7mQpPOjV+3HJJKSy21LwD05F2eB+ExI3a3/Ob9VNqZJ3/ 2T8eP3R6utGPggBhnHYLjqAM00tMlbg87BOypFo8NVo93X06S0DIdhpphBBDfiv3Bfko ZZ4iKqE6x+bB//oPh08PH4NhEfMlgopFbke52tW2JJtobqIo/NCiYqY6AKGI2d2DgxPE VM5A== X-Gm-Message-State: AOAM531kXbJddTz4h6vZUJGkUVJrXEnXU+FwoyfD5A8wfyRdvFyZVS+y F8az4dzw3BypKehwvSUOSF82MNRwQM70BQ== X-Google-Smtp-Source: ABdhPJziUekeQSoxY/vnLJt0AjxRNJMNiFL4v8tEAQDKBfmmwU9rMMF2C6jhGixWprc2YMQbytfYdQ== X-Received: by 2002:a5d:47af:: with SMTP id 15mr33317453wrb.205.1614196333031; Wed, 24 Feb 2021 11:52:13 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:12 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 24/35] userdiff tests: move away from "RIGHT" in perl.sh Date: Wed, 24 Feb 2021 20:51:18 +0100 Message-Id: <20210224195129.4004-25-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The "RIGHT" token is no longer magical, see recent changes to t/t4018/README. Let's change it in the recently moved perl.sh tests. This change was done separately so the earlier commit could benefit from the "diff --color-moved" detection. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/perl.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/t4018/perl.sh b/t/t4018/perl.sh index ac8fff7417a..b53b759353b 100755 --- a/t/t4018/perl.sh +++ b/t/t4018/perl.sh @@ -5,9 +5,9 @@ test_diff_funcname 'perl: skip end of heredoc' \ 8<<\EOF_HUNK 9<<\EOF_TEST -sub RIGHTwithheredocument { +sub withheredocument { EOF_HUNK -sub RIGHTwithheredocument { +sub withheredocument { print <<"EOF" decoy here-doc EOF @@ -19,9 +19,9 @@ EOF_TEST test_diff_funcname 'perl: skip forward decl' \ 8<<\EOF_HUNK 9<<\EOF_TEST -package RIGHT; +package Some::Package; EOF_HUNK -package RIGHT; +package Some::Package; use strict; use warnings; @@ -35,13 +35,13 @@ EOF_TEST test_diff_funcname 'perl: skip sub in pod' \ 8<<\EOF_HUNK 9<<\EOF_TEST -=head1 SYNOPSIS_RIGHT +=head1 SYNOPSIS EOF_HUNK =head1 NAME Beer - subroutine to output fragment of a drinking song -=head1 SYNOPSIS_RIGHT +=head1 SYNOPSIS use Beer qw(round finalround); @@ -59,9 +59,9 @@ EOF_TEST test_diff_funcname 'perl: sub definition' \ 8<<\EOF_HUNK 9<<\EOF_TEST -sub RIGHT { +sub asub { EOF_HUNK -sub RIGHT { +sub asub { my ($n) = @_; print "ChangeMe"; } @@ -69,9 +69,9 @@ EOF_TEST test_diff_funcname 'perl: sub definition kr brace' \ 8<<\EOF_HUNK 9<<\EOF_TEST -sub RIGHT +sub asub EOF_HUNK -sub RIGHT +sub asub { print "ChangeMe\n"; } From patchwork Wed Feb 24 19:51:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102377 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=-15.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,USER_AGENT_GIT 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 D1153C433E0 for ; Wed, 24 Feb 2021 19:55:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C6BB64EF5 for ; Wed, 24 Feb 2021 19:55:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235316AbhBXTzE (ORCPT ); Wed, 24 Feb 2021 14:55:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235156AbhBXTxh (ORCPT ); Wed, 24 Feb 2021 14:53:37 -0500 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 83D43C0611C1 for ; Wed, 24 Feb 2021 11:52:15 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id n4so1468567wmq.3 for ; Wed, 24 Feb 2021 11:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vNOrn2D42zwmMKMbMtfUy7eKTPbwLRpRQ311kcCd28E=; b=DVK9fWmBVOa3xCmxCLHqiSpkugqYn5gTTzi6cNapyHDz0jpalA0qCy5mlTbrNkKeB2 IZ1E03NQAv+DnJ3XLzLefsXPxHmX0ReRGs+ZqJTPj4ROCC3ra6FJNrV7DGgwWyBVUsQZ c30IvzaVQz3Pm4J65ilTfbi8fqFu5mZGlAfbAiwsWVBsIbI0NkUIT6eZIB0+DJ5HlSrp KB6urV4i2StL5Wy0cGsldnJAW0/elSVh4LMue8Vxl60WMpG/jUPQ2oAQfOQBooUtiL/O SYxA3fAWi4KJ4HP1VVcQSsxl52nLHdfvdzpOR/3r6kCUTdWm3jtuJCSI4jRTR4gFWcus LKNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vNOrn2D42zwmMKMbMtfUy7eKTPbwLRpRQ311kcCd28E=; b=jkGJQFQNq1xt6qgn/yp9YJmGm2xpTbYc51YMrADH66BQDSCNqpRf7qpgWhHFi1XaQl MLxd3QedZ8xSwYPgM7l24HyPlF0gobtu53lbo/SPjswnzw3NsW/5a36VqtwI7GOCnGVq oRYz3kw1M7gei54YAmond91Ec9ej30WYVfjpHJZv94VVtd3QAJwVvwObw5RKPQugO12Z 5bPjIVIV7vBeRlOSrKtFLqxwrhLem6ALUHewhRHxyPrzRQG9/JHLwhvzytIJPR87SFzK 5KBjp2ULFWf2HAiM7u/kaSjU9+dtDKb2NIjWLAl/bm0oXpJxRIWDYmjliHEEXtGHAdGp DdsA== X-Gm-Message-State: AOAM53324VY59+RdFaI1WApFmxiQxjrGjwS/MgCgboh1kzF4OvPraLfU Q0QsxEGeZI1qCa2g958CLY95W0OnuRLH6w== X-Google-Smtp-Source: ABdhPJx0imn1+bw6y13hVwO8xN6fIDvP4jeo0pelSVbEjl6HhGDxq+1XJxl7BMJ/ddPdgRjCbZSbcg== X-Received: by 2002:a05:600c:210f:: with SMTP id u15mr5037951wml.119.1614196333954; Wed, 24 Feb 2021 11:52:13 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:13 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 25/35] gitattributes doc: document multi-line userdiff patterns Date: Wed, 24 Feb 2021 20:51:19 +0100 Message-Id: <20210224195129.4004-26-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Document the multi-line userdiff patterns and how their matching and the negation syntax works. These patterns have been supported since f258475a6e (Per-path attribute based hunk header selection., 2007-07-06), and have had their current semantics ever since 3d8dccd74a (diff: fix "multiple regexp" semantics to find hunk header comment, 2008-09-20). But we had no documentation for them, let's fix that, and also add tests showing how some of the things being discussed here work. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/gitattributes.txt | 38 ++++++++++++++++-- t/t4018/custom.sh | 70 +++++++++++++++++++++++++++++++++ t/t4018/perl.sh | 16 ++++++++ 3 files changed, 120 insertions(+), 4 deletions(-) diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index 62c1147ba97..8082ff1ee73 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -794,12 +794,42 @@ backslashes; the pattern above picks a line that begins with a backslash, and zero or more occurrences of `sub` followed by `section` followed by open brace, to the end of line. -There are built-in patterns shipped as part of git itself. A more -advanced version of the `tex` pattern discussed above is one of them. +Multiple patterns can be supplied by listing them one per line +separated by `\n`. They will be matched one line at a time, e.g.: + +------------------------ +[diff "perl"] + xfuncname = "!^=head\n^[^ ]+.*" +------------------------ + +Patterns in a list of multiple patterns that begin with "!" are +negated. A matching negated pattern will cause the matched line to be +skipped. Use it to skip a later pattern that would otherwise match. It +is an error if one or more negated patterns aren't followed by a +non-negated pattern. + +To match a literal "!" at the start of a line, use some other regex +construct that will match a literal "!" without "!" being the first +character on that line, such as "[!]". + +If the last pattern in a list of multiple patterns ends with "\n" it +will be interpreted as an empty pattern, and will match the first +empty line. It's almost always a logic error to provide a list of +multiple patterns ending with "\n", but it's permitted in case you +genuinely want to match an empty line. + +If the pattern contains a `$1` capture it will be used instead of the +entire matching line (`$0`) to display the hunk header. This can be +used e.g. to strip whitespace from the beginning of the line, or to +only display the function name as part of a longer function +definition. + +There are built-in patterns shipped as part of git itself, see the +full listing below. For built-in patterns, you do not need `diff..xfuncname` in your -configuration file as discussed above, but if present, it will -override a built-in pattern. +configuration file. If present, it will override a built-in pattern, +as shown in the `diff.perl.xfuncname` example above. Nevertheless, you need to enable built-in patterns via .gitattributes` for the pattern to take effect. diff --git a/t/t4018/custom.sh b/t/t4018/custom.sh index 72d38dad686..127524afda3 100755 --- a/t/t4018/custom.sh +++ b/t/t4018/custom.sh @@ -111,3 +111,73 @@ ChangeMe baz EOF_TEST + +test_expect_success 'custom: setup negation syntax, ! is magic' ' + git config diff.custom.xfuncname "!negation +line" +' + +test_diff_funcname 'custom: negation syntax, ! is magic' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +line +EOF_HUNK +line +!negation + +ChangeMe + +baz +EOF_TEST + +test_expect_success 'custom: setup negation syntax, use [!] to override ! magic' ' + git config diff.custom.xfuncname "[!]negation +line" +' + +test_diff_funcname 'custom: negation syntax, use [!] to override ! magic' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +!negation +EOF_HUNK +line +!negation + +ChangeMe + +baz +EOF_TEST + +test_expect_success 'custom: setup captures in multiple patterns' ' + git config diff.custom.xfuncname "!^=head +^format ([^ ]+) +^sub ([^;]+)" +' + +test_diff_funcname 'custom: captures in multiple patterns' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +foo +EOF_HUNK +sub foo; + +=head1 + +ChangeMe + +EOF_TEST + +test_expect_success 'custom: multiple patterns ending with \n' ' + git config diff.custom.xfuncname "!^=head +^sub ([^;]+) +" +' + +test_diff_funcname 'custom: multiple patterns ending with \n' \ + 8<<\EOF_HUNK 9<<\EOF_TEST + +EOF_HUNK +sub foo; + +=head1 + +ChangeMe + +EOF_TEST diff --git a/t/t4018/perl.sh b/t/t4018/perl.sh index b53b759353b..ba11241750b 100755 --- a/t/t4018/perl.sh +++ b/t/t4018/perl.sh @@ -76,3 +76,19 @@ sub asub print "ChangeMe\n"; } EOF_TEST + + +test_expect_success 'custom: setup config overrides built-in patterns' ' + git config diff.perl.xfuncname "!^=head +^[^ ]+.*" +' + +test_diff_funcname 'custom: config overrides built-in patterns' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +sub foo; +EOF_HUNK +sub foo; +=head1 + +ChangeMe +EOF_TEST From patchwork Wed Feb 24 19:51:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102397 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=-15.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,USER_AGENT_GIT 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 77175C433DB for ; Wed, 24 Feb 2021 19:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4035264F08 for ; Wed, 24 Feb 2021 19:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235467AbhBXT5o (ORCPT ); Wed, 24 Feb 2021 14:57:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235207AbhBXTyC (ORCPT ); Wed, 24 Feb 2021 14:54:02 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4760EC0611C2 for ; Wed, 24 Feb 2021 11:52:16 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id u14so3051928wri.3 for ; Wed, 24 Feb 2021 11:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IkBGGjQHAjplwjvCfMMn7O/Kdu3StAf66jdZrlVtz40=; b=W7uXYowYDfv4/Yb+58jMLseEjOYMdJB5aV4eBWs4OWE3mkr3BEV4eRDmwBbO1f4gWl 5LgXDTefJLFkx9q2RWV1qaUSQW36dJ1QAy569NpfWgcIzuEP1RONq8bkDvxj3NI7yFGF 5AeyyCTWGsZZLyvBgq+2E32C9D3dhE/UrrPfVP5YligD5MDL/rh14Kk9+Oy5Sd0/Wiha TSsOtsq+o3Cphn1xH/iWRl5kPVKw77Qo+ST/Hgq1RUPMfOtv2Ox8ZN6KLaAvnI819fcU 5aqLeYN6gyhmuG+u57CnDhxzLPqVcqEenyzJPrYQCr3YGEeD6UJdTE+OwJIVyew3NLwj YpLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IkBGGjQHAjplwjvCfMMn7O/Kdu3StAf66jdZrlVtz40=; b=LTHRrDbdqdoN/nQixpyuaoHLZtxsJX5wgTHzVTbaNvFCEd2w65qhJWw/2VIOs0hfw3 zzNsNGP7sSWeD4m9P3JJ/zsQk+OZKu45kFAiPDdvuBEafkJvAYM4pjd8LUNs0kbF15go k/u++vwUDi0DSyvYDRBKDDMSjE2v/B/6gsFktOmeMXkuzp9z6VD6GQCHzZ5zjPFH7wpy nh/NdN/2CU342Zggv5ioKhBVPka+DzF6K9E+enVVhBSTNkVUa4zudz6FxHEGOqjMNPrV b5/dCjLoXtQQpnZOZgpYKIcv+p/HKccZa3jfGNC4jp7iowwFxXsRZrItZTDCPpD1bwTp QV/w== X-Gm-Message-State: AOAM530NxTlc4ogaW3bUcnZ6IoJyL+yN2OdrZ1VDyvr0B49PDtfi/t3d xH/eNJs964aehemvo2LphGnM60nEz+dmAA== X-Google-Smtp-Source: ABdhPJxGGuB3y0RzD823PEEiCTESieZBJFZHv7lG7Y0rvMaN1A3fGwNtmS1D5WVcW0EkfSfhukCb9g== X-Received: by 2002:adf:9564:: with SMTP id 91mr32313973wrs.207.1614196334766; Wed, 24 Feb 2021 11:52:14 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:14 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 26/35] userdiff tests: switch to -U0 by default Date: Wed, 24 Feb 2021 20:51:20 +0100 Message-Id: <20210224195129.4004-27-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the -U1 default in the userdiff tests to -U0. There's no reason to use -U1, it just causes confusion and the need to work around the test semantics themselves by not having the matching line immediately precede the changed line. The -U1 was initially added in f12c66b9bb8 (userdiff/perl: anchor "sub" and "package" patterns on the left, 2011-05-21), seemingly to appease a specific test I'd reported as failing with the "perl" pattern. This was then documented in bfa7d01413b (t4018: an infrastructure to test hunk headers, 2014-03-21). There's no special logic in xdiff/xemit.c that would depend on -U1 v.s. -U0 here. So let's use -U0 for simplicity, we're interested in what lines match most of the time, not at which line we start the search. A couple of test cases depended on the -U1, most confusingly one of the custom.sh test cases. Let's extend "test_diff_funcname()" to take an argument to "git diff" and test "-U1" there, both because rewriting the testcase would be painful to understand in the context of reviewing this change, and so that we explicitly test that we're using -U0. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 5 +++-- t/t4018/README | 7 +++---- t/t4018/custom.sh | 1 + t/t4018/perl.sh | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index a3058fda130..ca23d156666 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -104,7 +104,7 @@ do " test_expect_success "hunk header: $i" " - git diff -U1 $i >diff && + git diff -U0 $i >diff && last_diff_context_line diff >ctx && test_cmp t4018/$i.header ctx " @@ -112,6 +112,7 @@ done test_diff_funcname () { desc=$1 + diff_opts=${2:--U0} && cat <&8 >arg.header && cat <&9 >arg.test && what=$(cat arg.what) && @@ -124,7 +125,7 @@ test_diff_funcname () { ' && test_expect_success "$desc" ' - git diff -U1 "$what" >diff && + git diff $diff_opts "$what" >diff && last_diff_context_line diff >actual && test_cmp expected actual ' && diff --git a/t/t4018/README b/t/t4018/README index a3220dd6374..cef7d3c0e17 100644 --- a/t/t4018/README +++ b/t/t4018/README @@ -5,11 +5,10 @@ How to write test cases There are two ways of writing tests in this directory. In both cases "LANG" is the userdiff driver name, e.g. "perl" or "cpp". -The word "ChangeMe" (exactly this form) should appear at a distance of -at least two lines from the line that must appear in the hunk -header. See below sections. +The word "ChangeMe" below the line that must appear in the hunk header +(we run the diff with -U0). See below sections. -t4018 header: t/README. +t4018 header: The content of the "EOF_TEST" argument is used as-is, with the "LANG.sh" test cases ==================== diff --git a/t/t4018/custom.sh b/t/t4018/custom.sh index 127524afda3..97f310c02fb 100755 --- a/t/t4018/custom.sh +++ b/t/t4018/custom.sh @@ -10,6 +10,7 @@ test_expect_success 'custom: setup non-trivial custom' ' ' test_diff_funcname 'custom: non-trivial custom pattern' \ + '-U1' \ 8<<\EOF_HUNK 9<<\EOF_TEST int special, RIGHT; EOF_HUNK diff --git a/t/t4018/perl.sh b/t/t4018/perl.sh index ba11241750b..63f373d1a43 100755 --- a/t/t4018/perl.sh +++ b/t/t4018/perl.sh @@ -89,6 +89,5 @@ sub foo; EOF_HUNK sub foo; =head1 - ChangeMe EOF_TEST From patchwork Wed Feb 24 19:51:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102381 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=-15.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,USER_AGENT_GIT 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 0439DC433DB for ; Wed, 24 Feb 2021 19:55:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B371764EF5 for ; Wed, 24 Feb 2021 19:55:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235332AbhBXTzh (ORCPT ); Wed, 24 Feb 2021 14:55:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235165AbhBXTxh (ORCPT ); Wed, 24 Feb 2021 14:53:37 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15921C0611C3 for ; Wed, 24 Feb 2021 11:52:17 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id p3so2804629wmc.2 for ; Wed, 24 Feb 2021 11:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pw0jiAt1I2gW1fsZvZD72j6GVu7NokPW1exD1z5oArU=; b=r4isYiN95m0o5h/fy1hfzobYAFEjAPUN0nareo/1kmA80dIRLc75qWm71WiO3bNaja 9Rh9LXie4IuAQaJZp2kAESJB/GLeZKd9t7R5Xcuj25Zc4aqf9ka+KpioXvkfC7KmTUCc uUWHfMIohxFD2Jg5zE1ISkkwtuG4kVPrxsuNvjBdTM4/qaOua8znn06pRX2Z64/O9I1c 4QTB6cI0rPzMIzN7bUYRHLByKOlh8NVAXy67ROlGiPcz2QIkAb+wcE1n/NUCBc8fhcDM Ndreay21D0xq/yaTvK8P4zop/LXvFZVnQwYT46ctAHOVCpRe5Bl7n663VjqSNoc6C9Aq O2Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pw0jiAt1I2gW1fsZvZD72j6GVu7NokPW1exD1z5oArU=; b=gJ9Md8UCxg/cXwkRwe1msnJkOcnhYxPF2x7A6KOsTh7NTGsdDnC6UjsDqpF+mVdXcp A91d3WqifN+jC66e+Hqg9mqDGqJgGd/+SvLHEmKAVlFvEZ8WC94FOA9USLah9yAnTwN+ Yz5KDITtV25S8ZHfMk6cONTmFxwYkCqwkvxr3FsNEjm/wujIoiqBhVC/15XrA2kEpnPK RrRT9B1+yRqV1Xd7MA0AAo4RbYv2dKTNqsh877Kyy94Zfjpn/KI+gYp2cXEGP7+o+LzP 2+2OxKJJfsj7t6JPxfM3pN/miE+Hl1Yp9CLlrwH7kNopG7xEGME/MZNHUDnvsR/a2I/n raMg== X-Gm-Message-State: AOAM532x7r4S+aWCNakfBipIvyxhar6+uL8tx96GuELZH6l2rL0Xsa4y Uu+jD6I2wZFcJl4nmyRb1PtoGkgDTVd2Mg== X-Google-Smtp-Source: ABdhPJxv+rgZ9LLe9oXPjPaUGoQo/hy2aBR3IZTgdF8JBdC+3K5TUUEzKJ/koEN88rKvxnfNJ8mnow== X-Received: by 2002:a1c:107:: with SMTP id 7mr5157273wmb.28.1614196335595; Wed, 24 Feb 2021 11:52:15 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:15 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 27/35] userdiff tests: remove "funcname" from custom3 test Date: Wed, 24 Feb 2021 20:51:21 +0100 Message-Id: <20210224195129.4004-28-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We can only have one "funcname" or "xfuncname", any later definition overrides the earlier one, so this configuration wasn't doing anything. When this test was originally added in 3632cfc248 (Use compatibility regex library for OSX/Darwin, 2008-09-07) we had no such definition of two patters for this test. Back then this was setting the "diff.java.funcname" configuration variable. The stage for that second pattern being set got set later. In 45d9414fa5 (diff.*.xfuncname which uses "extended" regex's for hunk header selection, 2008-09-18) the pattern got converted from "funcname" to "xfuncname". Soon after in b19d288b4d (t4018-diff-funcname: demonstrate end of line funcname matching flaw, 2008-10-15) another test immediately preceding this one got added, using "diff.java.funcname" for its configuration. Then f792a0b88e (t4018 (funcname patterns): make configuration easier to track, 2011-05-21) came along and codified this whole thing when converting the two tests from "git config" to "test_config". Since this was never the intent of the test let's just remove this, the rationale in f792a0b88e for having some test for the clobbering behavior makes sense, but I'll do that in another follow-up test, not as a hard to read side-effect of this one. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/custom.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/t/t4018/custom.sh b/t/t4018/custom.sh index 97f310c02fb..58187c2293b 100755 --- a/t/t4018/custom.sh +++ b/t/t4018/custom.sh @@ -52,7 +52,6 @@ public class Beer EOF_TEST test_expect_success 'custom: setup alternation in pattern' ' - git config diff.custom.funcname "Beer$" && git config diff.custom.xfuncname "^[ ]*((public|static).*)$" ' From patchwork Wed Feb 24 19:51:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102401 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=-15.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,USER_AGENT_GIT 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 3BC81C433DB for ; Wed, 24 Feb 2021 19:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E761464F07 for ; Wed, 24 Feb 2021 19:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235189AbhBXT5v (ORCPT ); Wed, 24 Feb 2021 14:57:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235211AbhBXTyC (ORCPT ); Wed, 24 Feb 2021 14:54:02 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB480C0611BC for ; Wed, 24 Feb 2021 11:52:17 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id j187so2806274wmj.1 for ; Wed, 24 Feb 2021 11:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VTwTfO2Vsf34BBWSStSex3cH9HB1CCCFG4WlnLZ4Jis=; b=NOB2adVFe3SG0O4Ej+Uoutb3y12KsOZC81iCyROwIqQHSWCKN3B6cNjVLB7w/VZvjv 2m9vB9E++R7ZVe+VLTrBgzrHMRBJZLEtLUgAfVXsY8X4KYbrVhE2+LRwxkSyp5YY5Kdi tfKIcS7qxFEFuOptEm9k9eiQYsiu1YnxoYrWlvp7XMBP0S9uIyk60AMz8CfyXvlOZjff ZnyP/9sBrNBaVDVgz/s6IsLJ5tX2YDIneSDin3P+gkTUQNRlx0OQMB3Mx0VyDBw6Ohnr I/1CcoCWburDUTdLJ+HlL7kQDC1eKcVZyhLtlNQJ3Vk4GXPlaw8ESqIN8DIr5sbfU4+I 65GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VTwTfO2Vsf34BBWSStSex3cH9HB1CCCFG4WlnLZ4Jis=; b=gJU37ipdZsKmAK0TBB7+HgM1aPTSFgDUbwrsLr9NaJGuN4Mf7q93qlm+IQ1SI+2yG0 TABc3BCGN8L4s9gh3ovxPAykv0vSTkXFDcvr7B1hJB5RtY4Az9fj2x+PzuXMtCxiBf1b nAPnQ8Qfm8vTyVU503xmC0VA28D0Uvj33pEe+kjhTRmVnRcxt3aS3nd95LG+3P3LpA33 4teVlwHIuz7LR9cKfO3qRQrHDiu6yszz4/RvViJW+Hx0YZ9FnDoX7gCzGR3mYkaI+xNx 6UUBMW9hqH7WxRYiJgYQgMIGBU0VerHOPgU/g1Fxb7pTRRrZR1992kwLbJ6fKkw47HSP Toog== X-Gm-Message-State: AOAM5326PEI2DI6/HVLMdNUXZZCMFk6l8FlCtSEU9/ukP8KotppnL05T mfilTDzCzTxes8lUoT+i/o7ehrWPjX5MgA== X-Google-Smtp-Source: ABdhPJzrQUKjRrffT/5kwi0E3aDa2IA801Bx8Qw8bW6HTDFsJHa0EjxowUMbLhVFU91WQdCA3lC0TA== X-Received: by 2002:a1c:7312:: with SMTP id d18mr5162696wmb.155.1614196336307; Wed, 24 Feb 2021 11:52:16 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:15 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 28/35] userdiff tests: assert empty hunk header context on -U Date: Wed, 24 Feb 2021 20:51:22 +0100 Message-Id: <20210224195129.4004-29-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Assert the existing behavior that under -U we'll show no hunk header context, where takes us past the potential hunk header we'd have extracted. I'm just picking a number over nine thousand as a really large number we're unlikely to exceed in these tests. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index ca23d156666..ba10d1f5313 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -130,6 +130,13 @@ test_diff_funcname () { test_cmp expected actual ' && + test_expect_success "$desc -U9001" ' + git diff -U9001 "$what" >diff && + last_diff_context_line diff >actual && + echo >blank && + test_cmp blank actual + ' && + test_expect_success "teardown: $desc" ' # In case any custom config was set immediately before # the test itself in the test file From patchwork Wed Feb 24 19:51:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102387 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=-15.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,USER_AGENT_GIT 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 85887C433DB for ; Wed, 24 Feb 2021 19:56:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4888864F06 for ; Wed, 24 Feb 2021 19:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233291AbhBXT4T (ORCPT ); Wed, 24 Feb 2021 14:56:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235182AbhBXTxl (ORCPT ); Wed, 24 Feb 2021 14:53:41 -0500 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 A2D01C0611BD for ; Wed, 24 Feb 2021 11:52:18 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id l13so2893742wmg.5 for ; Wed, 24 Feb 2021 11:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RzixICTvEWBkooTXMVAoZaLGLhnvA7AjnnRsLjhnhWE=; b=g0zKH+X3GEmyhnEq6mV80CKYHKpwTAnHr/yCiFFCHD5poW1vokyENUPIG3UU3Frok3 6ExnsXbT8aECvemizKthhm3nR4rJ5zU6f8tQ6hU4XwNS5gjH8W5mdyjtr3UlrCvSnNKz JH0Gnm6qA25lTs+qxuYM8px+0Pd3Lrx5/3crFsTAv3bYX0tH+BujwP8KtLjT6c969YS3 7sMNYjss2o9sZi6QsIKBl7yPY8qIL7d4yAqYOBAAWwYQntr4o49kOzWGrcpmhbuUDNd6 C3wx5uN8E029kq2wtH6idgHWlzARnxVscBxqpZQzmzwN1/S0BzaFoGAT9kCIdIieuYw4 TMhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RzixICTvEWBkooTXMVAoZaLGLhnvA7AjnnRsLjhnhWE=; b=MgujRV+DyYw5DoEHXm0CuTXYis6NskZtr4JBhkNGDRKH4SuepDsQBRn32i2NhanfhS OTw5WDO7RrDk/2FGC/kDl9CO/2dj+GehINFTVHDfsiX6lx7yI4jqq/JhkRjyT2drw2gP zBrCi51Z3hSk6tI/K37tHXAN9ZV4uwqp2NYgy+L4nrvGDHZad/YuA15Qq43vdYrauF0X mtTtR4klVkJN7rRxAAwOIPhVPNwSNuqIT4qcXXWua3H5bpOJsRJukZU9CD5bizpnyqV2 68mI3TukmZejwYjsCQO8E+Xe04nEau3zAaRci/0WBzcV5Jjbalc9g1mGMEZO01A/oT6o dwWg== X-Gm-Message-State: AOAM533oZ1BP5QM2ZzCfMy7TYidkhGiDMt/Hoxs/0ohDpAmpc16otKiy iV7BLkmv6d5Tk2Ghm9H7dEHVw/pYNciANw== X-Google-Smtp-Source: ABdhPJy+qQPQdQgzy8hJHKS73aL2ha1KQ9EMax3xpU7BbGejpbraqIlEfRq2lsBPBiwDtmx1kcBgYw== X-Received: by 2002:a1c:32c4:: with SMTP id y187mr5243875wmy.120.1614196337179; Wed, 24 Feb 2021 11:52:17 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:16 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 29/35] userdiff tests: test for a bug in 1dbf0c0ad6c Date: Wed, 24 Feb 2021 20:51:23 +0100 Message-Id: <20210224195129.4004-30-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a test for a bug in 1dbf0c0ad6c (userdiff: add built-in pattern for golang, 2018-03-01), we'd ignore everything after the "{" only for "type" lines, but not "func". Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/golang | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/t/t4018/golang b/t/t4018/golang index 000e66b1c7b..70bf0d936bb 100644 --- a/t/t4018/golang +++ b/t/t4018/golang @@ -16,6 +16,13 @@ func RIGHT() { b := ChangeMe } +t4018 description: func with comment after { +t4018 header: func name() { // comment +func name() { // comment + a := 5 + b := ChangeMe +} + t4018 description: interface t4018 header: type RIGHT interface { type RIGHT interface { @@ -37,3 +44,10 @@ type RIGHT struct { a Type b ChangeMe } + +t4018 description: struct with comment after { +t4018 header: type some struct { +type some struct { // comment + a Type + b ChangeMe +} From patchwork Wed Feb 24 19:51:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102413 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=-15.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,USER_AGENT_GIT 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 6A7AAC433DB for ; Wed, 24 Feb 2021 19:59:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D0BB64F07 for ; Wed, 24 Feb 2021 19:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234883AbhBXT6R (ORCPT ); Wed, 24 Feb 2021 14:58:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235216AbhBXTyG (ORCPT ); Wed, 24 Feb 2021 14:54:06 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1747C0611BE for ; Wed, 24 Feb 2021 11:52:19 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id b3so3044023wrj.5 for ; Wed, 24 Feb 2021 11:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K/fsd2VG4GOQiR+Nooo9Lnum3PSHeDE72mO1dzh5WAE=; b=mtJ4q0zOegNKcL96OV9E6rBCkxlcflMy3iNDUB3CBkqvEEpgp/pmBeV2ywgQHNpiXO 8DUtnFMFmL1BYu7Jau0/0k3Ycn1NwHL5JkD3LrJeZXN09A6RCwYRg40KRbUktICZqxIL MpsIpq6526EW1e6HMw5EPR9CEedvk6wvTDlBFkP1xJD6RzYKa9n5ZQlp2WSkAZxq4Ghz Fb1hvMqXWYshTtFFWzqW9TkJzT6BTPnzGhn5/jxBJBqovGKSQhs3khpKA2d+UFrm6TpH 6sZx6nuhDYw1o7p5mrxhGdtwWlMcJNkWU23Kjne2vvhtJDil5zqytC8ufE4ohaTNMkFb B3bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K/fsd2VG4GOQiR+Nooo9Lnum3PSHeDE72mO1dzh5WAE=; b=V6ji4+E+0KDxMXWTVbtoAB3T6adMdBRTrqr1/AYanE6f+Cod75b1F5yeqG+61k1v84 QA6n4PVJUOQ9gwpBChyGnPLCG5viJbrx2XfSM7jAdYayIrbEKKgpvrQBIpamTmwpTa4u XgS+T2Zs0bArZS3GOOU3IgadIjtPQJAsGg3Kz0ykX/C2s9qNJp78yVelshpPpDOvTbG+ tjuaRwBduIfIwvLYFHOx/Iwa6tLKfjHEb6fsaMa5UN8M7N4I/Qul9TRhe2FAhaQVNcW0 uHg0Y+2bXWF41KqDWTQg5EecBm1depem1T0zVLcx20r0tDnt+nZ52sQk8kP5MI+yZCZu 4eAg== X-Gm-Message-State: AOAM5324Kew+pX1wFJy2mSXkDSJxdqGwgR5mhOzAPMbnK3Q9dnzFIdHx f4Y5wIynyJdElayXHlT1U00sNRZFVjGKZA== X-Google-Smtp-Source: ABdhPJxS/tpkq8wU9XY16GWIr9cZiAHHMOcAMg660O9gSeJYbGZVRlZnxJ3/3ia57cJuUwJbmUDaVw== X-Received: by 2002:adf:d239:: with SMTP id k25mr34532472wrh.308.1614196338106; Wed, 24 Feb 2021 11:52:18 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:17 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 30/35] userdiff golang: simplify and correct matching regex Date: Wed, 24 Feb 2021 20:51:24 +0100 Message-Id: <20210224195129.4004-31-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Simplify the regex for the golang driver added in 1dbf0c0ad6c (userdiff: add built-in pattern for golang, 2018-03-01) to remove redundant constructs. There's no point in having a regex like this: .*(foo)? When we can just write: .* In the "func" case, since the "(foo?)" match isn't mandatory it won't matter for the end result, and in this case we're not using the capture pattern. Not that it would matter since it's followed by a greedy .*, so we'd only get the empty string. In the "type" case we would stop at the "{", since it was not preceded by a ".*". This was a bug, if we have a comment or something else on that line we should include it. I'm also changing the "func[ \t]*.*" rule to "func[ \t].*" while I'm at it. We should always get whitespace after "func", so this narrows down our match. Let's do the same in the new "type" rule. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/golang | 2 +- userdiff.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t4018/golang b/t/t4018/golang index 70bf0d936bb..72a35d66008 100644 --- a/t/t4018/golang +++ b/t/t4018/golang @@ -46,7 +46,7 @@ type RIGHT struct { } t4018 description: struct with comment after { -t4018 header: type some struct { +t4018 header: type some struct { // comment type some struct { // comment a Type b ChangeMe diff --git a/userdiff.c b/userdiff.c index 55f4f769bd3..698eca5ad35 100644 --- a/userdiff.c +++ b/userdiff.c @@ -129,9 +129,9 @@ IPATTERN("fountain", "[^ \t-]+"), PATTERNS("golang", /* Functions */ - "^[ \t]*(func[ \t]*.*(\\{[ \t]*)?)\n" + "^[ \t]*(func[ \t].*)\n" /* Structs and interfaces */ - "^[ \t]*(type[ \t].*(struct|interface)[ \t]*(\\{[ \t]*)?)", + "^[ \t]*(type[ \t].*(struct|interface)[ \t].*)", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.eE]+i?|0[xX]?[0-9a-fA-F]+i?" From patchwork Wed Feb 24 19:51:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102403 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=-15.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,USER_AGENT_GIT 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 41867C433DB for ; Wed, 24 Feb 2021 19:58:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0788A64F07 for ; Wed, 24 Feb 2021 19:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234256AbhBXT60 (ORCPT ); Wed, 24 Feb 2021 14:58:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235147AbhBXTyK (ORCPT ); Wed, 24 Feb 2021 14:54:10 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 921C8C061A27 for ; Wed, 24 Feb 2021 11:52:20 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id c7so3040601wru.8 for ; Wed, 24 Feb 2021 11:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RSr0Gq027279ByhEI+zgUVoVtL+wMABxsiJm9gfkyPk=; b=C+3UW1HzEdUj8ouhg6uRZN9IHpZIi7OyiH42G3AsNPlh7kbWY4363V7kh14iQIAa+o LzRsosxBrhAiGT20QBa8smI0135+yEkV/BvZQ2dlvvHF50B50d2gXVt/PFaWJ+RHCg2g /gOxxoC8BYjy4BcNbc0DPWAq6I+od7YCQnVsBmxQ9N71TJ9K9BBQC8L2hiO/a5sbIicL sGOB4H8QtX3UMENvWlRddTDtVZxTEivgtc/M03+oVGL5vlRHZ1Re6bIVwQMVAMlq6QVR 2yAx1BlahRWzJ7tFy5hWzGyjCLoVmrGk/vyWvVif4dopnRPQJz2slRdxT44n9VYfjpt5 k4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RSr0Gq027279ByhEI+zgUVoVtL+wMABxsiJm9gfkyPk=; b=P+jP4ylxXVRICxKPL3mPuVw59RjBLiJVj/qNwHFgGynZXarQpgVMDHGlA61PpYGF7D WAHAuQMEB1alDDFh2UMUy2O3ytJZzmdx3pF6yH2pN4LSaGzldhu9SEQlY4mwghsdiNq4 OyOUyffljFXgMw7TlUGEtCBC/jO/uo+7Fb3npfzZOLUwfEI83cDrmHqvHueOG13gwbUa RUMOHiHagTH51MXamQMlhzNj87RnN0b0HaiEksGCMaFXwscW86sB77VcZ5REcy9qz6sO 1YjvJBEDUmyjPWwcBNeKuarrLOhlRBjpHcq/R/T1EyvMok6SLDLBSwuTj8YQ4b+8hWyg T6Zg== X-Gm-Message-State: AOAM533CunPwaA+XqabxCEM0OEHZkmPjlf3FneCRbjyYcQGvz5jQJmqY zWdr/BJnp/4c4l3Jo42xn6zW49rQzXcn/Q== X-Google-Smtp-Source: ABdhPJyLru16f64fWRIO83946eBrz9EPdW974lab99R9XVFdCrs567+8dQNkO/FZJCVSYL5tbokqWw== X-Received: by 2002:a5d:6643:: with SMTP id f3mr12007497wrw.182.1614196339037; Wed, 24 Feb 2021 11:52:19 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:18 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 31/35] userdiff golang: don't over-match intented constructs Date: Wed, 24 Feb 2021 20:51:25 +0100 Message-Id: <20210224195129.4004-32-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a bug introduced when the "golang" driver was added in 1dbf0c0ad6c (userdiff: add built-in pattern for golang, 2018-03-01). Unlike the default def_ff() driver in xemit.c it would match "type" declarations inside functions. Let's make it mandatory that a "func" or "type" must be at the beginning of the line with no whitespace to get around this. Go is such a regularly formatted language that I think this can be counted on. I think the whitespace matching was probably copy/pasted from an earlier userdiff.c pattern. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/golang | 20 ++++++++++++++++++++ userdiff.c | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/t/t4018/golang b/t/t4018/golang index 72a35d66008..252b6049da4 100644 --- a/t/t4018/golang +++ b/t/t4018/golang @@ -51,3 +51,23 @@ type some struct { // comment a Type b ChangeMe } + +t4018 description: func combined with type +t4018 header: func myfunc() { +func myfunc() { + type mystruct struct { + a Foo + b Bar + } + ChangeMe + +t4018 description: anonymous indented func() +t4018 header: func SomeThing() bool { +func SomeThing() bool { + func() { + defer func() { + fmt.Println("hello") + }() + }() + + ChangeMe diff --git a/userdiff.c b/userdiff.c index 698eca5ad35..704af241e44 100644 --- a/userdiff.c +++ b/userdiff.c @@ -129,9 +129,9 @@ IPATTERN("fountain", "[^ \t-]+"), PATTERNS("golang", /* Functions */ - "^[ \t]*(func[ \t].*)\n" + "^(func[ \t].*)\n" /* Structs and interfaces */ - "^[ \t]*(type[ \t].*(struct|interface)[ \t].*)", + "^(type[ \t].*[ \t](struct|interface)[ \t].*)", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.eE]+i?|0[xX]?[0-9a-fA-F]+i?" From patchwork Wed Feb 24 19:51:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102409 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=-15.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,USER_AGENT_GIT 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 92200C433E6 for ; Wed, 24 Feb 2021 19:58:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B02364F0D for ; Wed, 24 Feb 2021 19:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235147AbhBXT6m (ORCPT ); Wed, 24 Feb 2021 14:58:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235278AbhBXTyf (ORCPT ); Wed, 24 Feb 2021 14:54:35 -0500 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 62B7CC061A28 for ; Wed, 24 Feb 2021 11:52:21 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id n4so3060590wrx.1 for ; Wed, 24 Feb 2021 11:52:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qx7MgCeeFbGnardhIUUvIZHDrxcn4oD0CO88xRoqRvQ=; b=bVqYvkYdTIj83no1BE61TKxpFECKCbwxryQQZscUORu0IvPcbj11GK5M2lYBQXHpXe Ofxw40Gh3qiJsKAipA2DwQsB0s63JhQ7AwXBXDJq/M25gUfMuUJW3Qun6OrfIhDlSBk9 a/7q6CAHJJ6QDPsyoSY4fXZx0nAJtoWxBq7uGBi/VQusa0o1MYEXUO6iN8IyilWlVVRh QrN6PnOqvQy72XiWVlZZLS0n3UzNdeEssX50jJNqaNyLsBehcrD+yXqPLTOWlO1RME7D +W90A97Ed4l7qFfM6ieDTmKZBEpc9BSZ0y9X16GVXXtndMR9qYJFZYOW9Z8YdH4HwEJV yTDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qx7MgCeeFbGnardhIUUvIZHDrxcn4oD0CO88xRoqRvQ=; b=RNvwR2PC7MRVVldKux8ZSJht6IeHljLpjaDOAsQfChzCr6z7rApRyArhH7ibuJsdAC j68hC/tEvLImoP1XrXsE3lMo4KLarEJAA4hloY143FrWZCED1vkaH5uKHL4Pxo+vsiC1 InD6lPSRV/VQ+e1jWAGJWSUKgk29WRNFwpBdu4p300Z9Cx5EXi7aRX1MF225YY4PCYpr 5qJq7HXhaORPfIyw4sfTBIFL0gev7Zzsoa9a32fp2fRsoJYAk3jpHZAjRvPC/EkJAuNF zyrc110d2KKouW0G/LUJ4i/epRp4KEH6DLuOP16+duORcd9lsdOq1hT0W6R33TWt6kvM 6BGQ== X-Gm-Message-State: AOAM5316QdO6Jd14wMfxPmlF+CZPedjg1O+os+tg9l1vRUsihOKBxqK2 vsr5WFzK+C16BLDozz6xjCRYtvf6+SRV1g== X-Google-Smtp-Source: ABdhPJyZD9mQp2QdTvXY1k6QcfEE4PnIK03NmsoTFnzjzmaA7ArZOOHJWyqyShFvOOOf8sZhRQxIUQ== X-Received: by 2002:a5d:4050:: with SMTP id w16mr9968157wrp.21.1614196339817; Wed, 24 Feb 2021 11:52:19 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:19 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 32/35] userdiff golang: add a rule to match "package" Date: Wed, 24 Feb 2021 20:51:26 +0100 Message-Id: <20210224195129.4004-33-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Improve the "golang" built-in pattern to match "package" lines, as they weren't matched before changing e.g. the imports would commonly result in an empty hunk header, now we'll instead show the package name. I used https://blog.golang.org/package-names as a guide here, but e.g. "foo_bar" is still valid syntax, so let's let it pass but veer on the side of not having false positives. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/golang | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ userdiff.c | 2 ++ 2 files changed, 51 insertions(+) diff --git a/t/t4018/golang b/t/t4018/golang index 252b6049da4..38f254cd269 100644 --- a/t/t4018/golang +++ b/t/t4018/golang @@ -1,3 +1,52 @@ +t4018 description: package +t4018 header: package main +package main + +import "fmt" +// ChangeMe + +t4018 description: package regex is selective -- ALLCAPS +t4018 header: package main +package ALLCAPS + +import "fmt" +// ChangeMe + +t4018 description: package regex is selective -- CamelCase +t4018 header: package main +package CamelCase + +import "fmt" +// ChangeMe + +t4018 description: package regex is selective -- 123 +t4018 header: package main +package 123 + +import "fmt" +// ChangeMe + +t4018 description: package regex is not overly selective -- x509 +t4018 header: package x509 +package x509 + +import "fmt" +// ChangeMe + +t4018 description: package regex is not overly selective -- underbars +t4018 header: package not_conventional +package not_conventional + +import "fmt" +// ChangeMe + +t4018 description: package regex is not overly selective -- camelCase +t4018 header: package camelCase +package camelCase + +import "fmt" +// ChangeMe + t4018 description: complex function t4018 header: func (t *Test) RIGHT(a Type) (Type, error) { type Test struct { diff --git a/userdiff.c b/userdiff.c index 704af241e44..bbbbfa33e0a 100644 --- a/userdiff.c +++ b/userdiff.c @@ -128,6 +128,8 @@ IPATTERN("fountain", /* -- */ "[^ \t-]+"), PATTERNS("golang", + /* Packages */ + "^(package[ \t][a-z][A-Za-z0-9_]+)[ \t]*\n" /* Functions */ "^(func[ \t].*)\n" /* Structs and interfaces */ From patchwork Wed Feb 24 19:51:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102405 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=-15.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,USER_AGENT_GIT 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 4C312C433E0 for ; Wed, 24 Feb 2021 19:58:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F92C64EDD for ; Wed, 24 Feb 2021 19:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234317AbhBXT6c (ORCPT ); Wed, 24 Feb 2021 14:58:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235225AbhBXTyN (ORCPT ); Wed, 24 Feb 2021 14:54:13 -0500 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 4D6BFC061A29 for ; Wed, 24 Feb 2021 11:52:22 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id c7so3040670wru.8 for ; Wed, 24 Feb 2021 11:52:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E6p1RT5Ao+Of/2Rv/23jaShVDQn9w7IowFj2B2kyprs=; b=GJ0CjYjm8NmDPnWUX8yxHEojnlwXJpcc1pICQUV7whWZcoo3KRFuegcaJa8Y9zAe8p MxDAmH6kYUulyBXdavN9jIycTvuzBrh5euU6SU56r29Ft1+ed0AJI/LFwke4/uZcGB7w IW+gWuzYj/u2M12CsNxk6xuDSID7OrUZaEs1n7JnzZZtItxPRQ5bzBOUymWKwTy8De7X GNIgXhNXLBG9chJFoOhr4RCDaH3yT1eN5qZBNEP4a8ZFWX1CZ4RXspRQMi+w5+I6SMOJ SzpzXwQR8LgBO5q/R/gPojxEUmpyisD+oICeYa7WK0vhVPgAKBcvyJnhumoVvbdF94Kj QZoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E6p1RT5Ao+Of/2Rv/23jaShVDQn9w7IowFj2B2kyprs=; b=AumFYb+xbPZHwIwVLhealRDILrYiMpeN7zpIFL+JMX0G4Ced1T0QmPefE5nAQe75n1 oSRnfJhRsJt2oiykxyPYpHqU7lvp25rRtukm1X2OOiPWKvDuQvcqmSnwV3BXAHeH2fwD 7yXN/PAgKK5tnZoyseOA8Wt/yJgeJI2rBZodOWQNdDQ+QYV0iIab378CKuybYW4AwQ/Y FO8hYGj0dapItzxWkxsr+ZN1DIAxBvu3ouykZPnIfXX8+TI3IfPd7RTgg1gTKJf7nQfL LFRGluadnOpVApz/Ep/ugIcx8rsk6d4VfdE//kQJPhWmoiH3Mnd2+RTBZpBq49CzH5Tc FakA== X-Gm-Message-State: AOAM532/mJWTBbAJlv+xXRK/SMfN2OojQNj694TBkJGoj2ahQ8hqgI2a gjaheqVfU9R7im+I571JYbtO23MrafAEdg== X-Google-Smtp-Source: ABdhPJySppLI6U1TX8X6M4XulRsScqJ9PD4u7PU2vAbsqMUREKWYMVqOcRn36mHRAbGDm86SZLuhrg== X-Received: by 2002:adf:eb8e:: with SMTP id t14mr32860746wrn.20.1614196340792; Wed, 24 Feb 2021 11:52:20 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:20 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 33/35] userdiff golang: match multi-line "const" and "import" Date: Wed, 24 Feb 2021 20:51:27 +0100 Message-Id: <20210224195129.4004-34-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add matching rules for the very common pattern of having a multi-line "import" or "const" declaration near the start of the "package" line. Before this change we'd skip this and match whatever came before it, e.g. the "package" line. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018/golang | 26 ++++++++++++++++++++++++++ userdiff.c | 2 ++ 2 files changed, 28 insertions(+) diff --git a/t/t4018/golang b/t/t4018/golang index 38f254cd269..7f51fa02203 100644 --- a/t/t4018/golang +++ b/t/t4018/golang @@ -47,6 +47,32 @@ package camelCase import "fmt" // ChangeMe +t4018 description: import ( +t4018 header: import ( +package somePackage + +import ( + "os" + ChangeMe +) + +t4018 description: const ( +t4018 header: const ( +package somePackage + +const ( + Foo = 1 + Bar = ChangeMe +) + +t4018 description: const rule is selective +t4018 header: package main +package main + +const Foo = "Bar" + +// ChangeMe + t4018 description: complex function t4018 header: func (t *Test) RIGHT(a Type) (Type, error) { type Test struct { diff --git a/userdiff.c b/userdiff.c index bbbbfa33e0a..c4a2bfaed70 100644 --- a/userdiff.c +++ b/userdiff.c @@ -132,6 +132,8 @@ PATTERNS("golang", "^(package[ \t][a-z][A-Za-z0-9_]+)[ \t]*\n" /* Functions */ "^(func[ \t].*)\n" + /* const & import */ + "^((import|const)[ \t]*\\([ \t]*)\n" /* Structs and interfaces */ "^(type[ \t].*[ \t](struct|interface)[ \t].*)", /* -- */ From patchwork Wed Feb 24 19:51:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102407 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 69DA0C433DB for ; Wed, 24 Feb 2021 19:58:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30CED64F07 for ; Wed, 24 Feb 2021 19:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234751AbhBXT6g (ORCPT ); Wed, 24 Feb 2021 14:58:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235223AbhBXTyN (ORCPT ); Wed, 24 Feb 2021 14:54:13 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F2B9C061A2A for ; Wed, 24 Feb 2021 11:52:23 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id 7so3057077wrz.0 for ; Wed, 24 Feb 2021 11:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ca/3zP1uvWPzwHNhntK47F35wSo5USpHIJyKPA7UgRc=; b=uMXjZGJ1BR6Oe9wwcCLNuDSPP9CXOgmHqODDa7p57Ye3I7TuJ47sUhXx6rYxiiSWMZ mSmhwNjNMSU5v+Di3OZ/jB4ezqrK4xLrkndwIFZJolQMVD3gld3HiN48FIESofjHpyQw sxq8uEpB9Crd76GXXP0OdHHLwz0sZxYXNah7PpnxWrBucP/yE1g5fMxQ1Yr+YE8ho0zP UzOG5mXqVeH+cFb0apGnNX8WYGW1IdvPlyRSKdD1sQbrbJOEdz+wy2XYuGNHja0MIzmV FmWiqUxvo8N801jRIErT35FFO29FVz4+Y1/s8YWvzBfNygLHrEyF28fx7nKnwBSuvwXK Nr+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ca/3zP1uvWPzwHNhntK47F35wSo5USpHIJyKPA7UgRc=; b=RewZCspDkJl9FSNdV/Qd3HGQ92p3FGBYCLuNrt5QnhiXemlTwFEYJwAmx+5f9+z7WK PVTvNqgursrHZxLHyLXD+afcsz6tbbKh4IQ0Des/K0dMx03khBmHDfbZnwLsWIcEe3PG 7IVhX5nrLbu6YVyRHqI4F4iLyiY2QKwmvNpZd+soIPSk8texbpd45l/H0tV9XBbsRetj 5823CmANYdT8uhuX9WMKoR0nB9irp8S5C5iTPKUrHdfU+h2Szl1wIMrHa4NcFG9IywVz g3E7ALhriQDYHsULw+/RsuhNmmeuaPChL3qxDxTZE8K6I9Oy4UoGcV2YcN6pYPw6j5YU QRKA== X-Gm-Message-State: AOAM5311/tuu4fCUXXBsd26rK/6TlnKKPztVnjReY07BqYtQK0Dd/k9e IVuQ2yePp7Iwikv+hl3OizeUQOMOXNuAGw== X-Google-Smtp-Source: ABdhPJwTYQisDvWOvuXW7kD/30YYzs3ROpBdjk7PFH4OpExAPbG0i47GjfdwaEXZCUagL8EbagGgLw== X-Received: by 2002:a05:6000:1101:: with SMTP id z1mr33845760wrw.110.1614196341558; Wed, 24 Feb 2021 11:52:21 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:21 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 34/35] userdiff tests: add basic test for ada Date: Wed, 24 Feb 2021 20:51:28 +0100 Message-Id: <20210224195129.4004-35-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add test for the ada userdiff pattern added in e90d065e64 (Add userdiff patterns for Ada, 2012-09-16). I don't know the ada language itself, I just stole a couple of examples of code that used tokens we're matching[1][2]. Both test examples stress our negative and positive matching rules. 1. https://rosettacode.org/wiki/99_bottles_of_beer#Ada 2. https://en.wikibooks.org/wiki/Ada_Programming/Tasking --- t/t4018-diff-funcname.sh | 1 - t/t4018/ada.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 t/t4018/ada.sh diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index ba10d1f5313..b0c2782d067 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -18,7 +18,6 @@ test_expect_success 'setup' ' # Do not add anything to this list. New built-in drivers should have # tests cat >drivers-no-tests <<-\EOF && - ada bibtex csharp html diff --git a/t/t4018/ada.sh b/t/t4018/ada.sh new file mode 100755 index 00000000000..45fc2c7a3b2 --- /dev/null +++ b/t/t4018/ada.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# See ../t4018-diff-funcname.sh's test_diff_funcname() +# + +test_diff_funcname 'ada: "procedure" over "with"' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +procedure Bottles is +EOF_HUNK +with Ada.Text_Io; use Ada.Text_Io; + procedure Bottles is + begin + for X in reverse 1..99 loop + Put_Line(Integer'Image(X) & " bottles of beer on the wall"); + Put_Line(Integer'Image(X) & " bottles of beer"); -- ChangeMe + Put_Line("Take one down, pass it around"); + Put_Line(Integer'Image(X - 1) & " bottles of beer on the wall"); + New_Line; + end loop; + end Bottles; +EOF_TEST + +test_diff_funcname 'ada: "task" over "procedure"' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +task body Check_CPU is +EOF_HUNK +procedure Housekeeping is + task Check_CPU; + task Backup_Disk; + + task body Check_CPU is + -- Comment for spacing with + -- the above "task" for -U1 + ChangeMe + end Check_CPU; +end Housekeeping; +EOF_TEST From patchwork Wed Feb 24 19:51:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12102411 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=-15.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,USER_AGENT_GIT 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 BEB2FC433DB for ; Wed, 24 Feb 2021 19:59:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89CB164F09 for ; Wed, 24 Feb 2021 19:59:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235285AbhBXT6z (ORCPT ); Wed, 24 Feb 2021 14:58:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235286AbhBXTyi (ORCPT ); Wed, 24 Feb 2021 14:54:38 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA814C061A2B for ; Wed, 24 Feb 2021 11:52:23 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id e10so2825630wro.12 for ; Wed, 24 Feb 2021 11:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cVsRH/pRLpHiEheWqNzoRFeT+Q+1ia2kdJrwOg41Bk8=; b=h+CE7cOTETQ+WfSpQcHCbB0fpEgfHKTZ6RfMD6i69BkVI81gLZdzZzMgsOsjJEB4Md hCd2+NVpqN6cqzLZzUfDArQ3BdEHJI6WieOTU0ab5l0yH9UKOZruAYoewIGyLv98oldn 2pwMXRiAWjmV8Xzg3HP3fu9lTNwRDD2ibyWzdFIk4xu2BvxzROkGs3Iod6EFutGTSfAW +liYte+NKATXYSNEfD7pn3oFrMwoxazYNaAD+1egSRz8j6j4rt3yVB3kYvqxH9yJ3KH/ a2QYI/6+LPPKQiFc/XITYSYw+k55ZtwJU+My5z/oyUivL6PvuWTGjYw3vySZV3YxM28X In8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cVsRH/pRLpHiEheWqNzoRFeT+Q+1ia2kdJrwOg41Bk8=; b=ltUDbWO/7j25IfUClzE0SoF3AVsi5Deuh7gvrZpP/li0IBE7Y9r2Zl/Q4Xg/Iy9kS5 zuHVMVBWgEpoZOYw/wJf5Pzi0E0MfXXnepE2w1KoyZbYoX0g5j7aIdHwnDUeTSJYjG68 tFJJ5gfP1zojKGUMJy2G3Ithfs0taBy4dwGclNGk02WevLzXcqqLDRUd/fAcrUDSRU7d F+GSOOg1YKlq5UBV2mr2fSmX7bWOfuMad/bHHbkbFAFE5yjPN5tiOVmNTOewLtXBavAd GCh0mkCtppY5MvZwt27RDiETUFgVYIcTSBTLDs6t0mIZ1v/sW/3Hdmd7T18OH5uqO01G cDpw== X-Gm-Message-State: AOAM532VnK3j0XjK5wGue/GOdF2sdJ7Uc1iuzdA1BtXdNvB0hEuRMY1C tLeMoB1sITHzXcpUknPpe9Wu9RgxHTcWDA== X-Google-Smtp-Source: ABdhPJwUkiWr0apyqT0xjqchxbqu4TNufwn87rFd6+bcmAsBV94XFmjxIa/QpXN/rTJNBdjIYLtTJg== X-Received: by 2002:adf:bc01:: with SMTP id s1mr3418163wrg.240.1614196342398; Wed, 24 Feb 2021 11:52:22 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y2sm4786072wrp.39.2021.02.24.11.52.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 11:52:21 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Sixt , Jeff King , Jonathan Nieder , Philippe Blain , Adam Spiers , Eric Sunshine , Chris Torek , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 35/35] userdiff tests: add basic test for ruby Date: Wed, 24 Feb 2021 20:51:29 +0100 Message-Id: <20210224195129.4004-36-avarab@gmail.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7 In-Reply-To: <20210215154427.32693-1-avarab@gmail.com> References: <20210215154427.32693-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a test for the Ruby pattern added way back in ad8c1d9260 (diff: add ruby funcname pattern, 2008-07-31). The "One/Two" picking demonstrates existing behavior, and a general case where we may not do what the user expects since we're not aware of the indentation level. The code is modified from the Ruby code we have in-tree at Documentation/asciidoctor-extensions.rb. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4018-diff-funcname.sh | 1 - t/t4018/ruby.sh | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 t/t4018/ruby.sh diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index b0c2782d067..7793d7652d5 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -23,7 +23,6 @@ test_expect_success 'setup' ' html objc pascal - ruby tex EOF diff --git a/t/t4018/ruby.sh b/t/t4018/ruby.sh new file mode 100755 index 00000000000..ef8a154421a --- /dev/null +++ b/t/t4018/ruby.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# +# See ../t4018-diff-funcname.sh's test_diff_funcname() +# + +test_diff_funcname 'ruby: "def" over "class/module"' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +def process(parent) +EOF_HUNK +require 'asciidoctor' + +module Git + module Documentation + class SomeClass + use_some + + def process(parent) + puts("hello") + puts(ChangeMe) + end + end + end +end +EOF_TEST + +test_diff_funcname 'ruby: "class" over "class/module"' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +class Two +EOF_HUNK +module Git + module Documentation + class One + end + + class Two + # Spacing for -U1 + ChangeMe + end + end +end +EOF_TEST + +test_diff_funcname 'ruby: picks first "class/module/def" before changed context' \ + '-U1' \ + 8<<\EOF_HUNK 9<<\EOF_TEST +class One +EOF_HUNK +module Git + module Documentation + class One + end + + class Two + ChangeMe + end + end +end +EOF_TEST