From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 6796F207BD for ; Thu, 20 Apr 2017 21:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030773AbdDTVYo (ORCPT ); Thu, 20 Apr 2017 17:24:44 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35583 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S947811AbdDTVYm (ORCPT ); Thu, 20 Apr 2017 17:24:42 -0400 Received: by mail-wr0-f196.google.com with SMTP id l44so9433103wrc.2 for ; Thu, 20 Apr 2017 14:24:42 -0700 (PDT) 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=WwlaqKrw7klxJIFcFHvPpNKfNHawuhZRwSB2NcOUEpk=; b=aa9c0CVmxR5p2VzLVm0uDH4beTFioHhLNtWksYZWGNuh6RpRVj4PuNct8AFV4ehqEM z9H6qQLLKD+XjkO2OakrmS5of0WWB6Np3R2HE9wIlHRID+UHT3EnL//qz6iwk+Ua+xb8 z8RRqIEeofB0q9dOlHpHaxlHZytfPkzgO0ZdQ1TBrjGwer4shLCJs3H/LrWw2qBEahd0 kp3dcWKT69D+q/59oOAJxZFdvMuQOd/gki91YdwRc4D4K9WkPCUa4AE6IOUOYv6LBVtJ jRCqIxwuHgYk0T7tKFMacsIEHI6mj13Cg3W18YJHMDy/7xgoYGnyXFIoHZhTaP/sakwg cAWA== 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=WwlaqKrw7klxJIFcFHvPpNKfNHawuhZRwSB2NcOUEpk=; b=tC3uje1jTF5MKTIjvoMIpo2ms4oym7+6Foy/pMin9m8MODAeAu5gVN32ZPK90RNw5Q V/qF2ouCg3760WGdoAuR2i0I2ubNl1XycDAu4V7jE6Y6pOnynGfw4Lw4/4hljaddFYk8 2tCQh377f5PKdPtiYCXs83IywOBD+oKPJ/hdxjqZIi/ESAJGcLbFl081RU7EyHcYwo/C tmk/cMyvRaDLoM2SAPLOzTx8aB7AOX8oFRJtxI3FAbCxxk9Nz5XNBVcBL/v7GxkjfvCI RCClcoWmZLYePgVrXvyO4Q7FYDmD9pvvJdCq1D11uXDATXYnBqqJbRZLdxn8fPy3OqQU SsNg== X-Gm-Message-State: AN3rC/7XP5vb/kdeIZkk6+ZEHvnxUQgOH+s6czBm/Fo8cepGvJOJ3Bcw On8JgRyQUnHkqA== X-Received: by 10.223.176.184 with SMTP id i53mr4297074wra.53.1492723480308; Thu, 20 Apr 2017 14:24:40 -0700 (PDT) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id k63sm442322wmf.9.2017.04.20.14.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Apr 2017 14:24:39 -0700 (PDT) From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Jeffrey Walton , =?UTF-8?q?Micha=C5=82=20Kiedrowicz?= , J Smith , Victor Leschuk , =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= , Fredrik Kuivinen , =?UTF-8?q?Zolt=C3=A1n=20Herczeg?= , Brandon Williams , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Subject: [PATCH v3 08/18] log: add -P as a synonym for --perl-regexp Date: Thu, 20 Apr 2017 21:23:35 +0000 Message-Id: <20170420212345.7408-9-avarab@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170420212345.7408-1-avarab@gmail.com> References: <20170420212345.7408-1-avarab@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a short -P option as a synonym for the longer --perl-regexp, for consistency with the options the corresponding grep invocations accept. This was intentionally omitted in commit 727b6fc3ed ("log --grep: accept --basic-regexp and --perl-regexp", 2012-10-03) for unspecified future use. Since nothing has come along in over 4 1/2 years that's wanted to use it, it's more valuable to make it consistent with "grep" than to keep it open for future use, and to avoid the confusion of -P meaning different things for grep & log, as is the case with the -G option. As noted in the aforementioned commit the --basic-regexp option can't have a corresponding -G argument, as the log command already uses that for -G. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/rev-list-options.txt | 1 + revision.c | 2 +- t/t4202-log.sh | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index a02f7324c0..5b7fa49a7f 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -91,6 +91,7 @@ endif::git-rev-list[] Consider the limiting patterns to be fixed strings (don't interpret pattern as a regular expression). +-P:: --perl-regexp:: Consider the limiting patterns to be Perl-compatible regular expressions. Requires libpcre to be compiled in. diff --git a/revision.c b/revision.c index 7ff61ff5f7..03a3a012de 100644 --- a/revision.c +++ b/revision.c @@ -1995,7 +1995,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE); } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) { revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED; - } else if (!strcmp(arg, "--perl-regexp")) { + } else if (!strcmp(arg, "--perl-regexp") || !strcmp(arg, "-P")) { revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_PCRE; } else if (!strcmp(arg, "--all-match")) { revs->grep_filter.all_match = 1; diff --git a/t/t4202-log.sh b/t/t4202-log.sh index fc186f10ea..06acc848b8 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -331,8 +331,17 @@ test_expect_success 'log with various grep.patternType configurations & command- --grep="(1|2)" >actual.fixed.short-arg && git log --pretty=tformat:%s -E \ --grep="\|2" >actual.extended.short-arg && + if test_have_prereq PCRE + then + git log --pretty=tformat:%s -P \ + --grep="[\d]\|" >actual.perl.short-arg + fi && test_cmp expect.fixed actual.fixed.short-arg && test_cmp expect.extended actual.extended.short-arg && + if test_have_prereq PCRE + then + test_cmp expect.perl actual.perl.short-arg + fi && git log --pretty=tformat:%s --fixed-strings \ --grep="(1|2)" >actual.fixed.long-arg && -- 2.11.0