From patchwork Sun Mar 24 08:19:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77D40922 for ; Sun, 24 Mar 2019 08:21:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6704929829 for ; Sun, 24 Mar 2019 08:21:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B8FF29830; Sun, 24 Mar 2019 08:21:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01C2D29829 for ; Sun, 24 Mar 2019 08:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728486AbfCXIVS (ORCPT ); Sun, 24 Mar 2019 04:21:18 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:35026 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIVS (ORCPT ); Sun, 24 Mar 2019 04:21:18 -0400 Received: by mail-pf1-f194.google.com with SMTP id t21so4312683pfe.2 for ; Sun, 24 Mar 2019 01:21:17 -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=Ik/UldvKgnqQWpze7cA9tPU5bbegyTpwMEKC5nUu6bI=; b=rJnE++oSFnyzSyrm/hIBn5P4yB8oB92DAG/2ipgLgpWb3v/RggMmS1O1xI0Bktm2Ht r+/6L2tyB3vGTs9/zclDxlT9xf+ahEm8FSvXqutRpHAF15Uq8GLfveIzj1JF/dpedfep 58QpOx+GNs75JWV1dXdWJgrtQcL2mP8kobjpxdSyugRi1l4aLqV2dECP7SH89KfA1sfc VThmbzqVXWV9P4bXrGJoHs/pEvATOHC7enh5pU0u1iQiNh2A54kODWQ7BElxKsrrOBIK ZMvVopCsW9oKMtGo81cERgrB8WbNa2eJL0Z+Nb4kMGVMbKMQH7ye9gtZmm+6RDtFki1K kwZg== 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=Ik/UldvKgnqQWpze7cA9tPU5bbegyTpwMEKC5nUu6bI=; b=B4bzOzxzuNHY1xm3JN0pNd3mTivbFPDL2zw5dubWV5RIryhtxK7AP50N2HCYKHxLPy HLwhWuPhxNwRyo1dXNMZlF7ZMyWR+/kxphCiQu9vo70PI4WD1/I2bqjZUmigjqxrjIoJ ZwFqfarz/KlL2rvvVAdxKf1OrZiU4/2INsVnqeoStGwrD8VYiIH55nM+iRBM00nvUlSM O+K8Fckn1fnqgpuPHQueLKrPdVsCmdLT/dZu69a8vBvBvZILNxsUdYKv06jUokXJKsGw 1HyFg+1cc8Yk3WWbXmZtX2G3h9EnS2n3znt3bi+Aq0EEfLjkCydscCoFzsXpPNpvDwXN UANg== X-Gm-Message-State: APjAAAUnYfcMA+SgnTLMNgm9021mGKoU5z1i3gDAzIOcuDc96Lx/b7y4 t8b+YZ8hsqEWyd7eDS9PoPI= X-Google-Smtp-Source: APXvYqxh4kYAc1fCxaKxZOCPxgt009MbSf+LnGocUZqrl55nnYq20LU83uIrHPtwaEX0L8YLMq7Y7w== X-Received: by 2002:aa7:82d9:: with SMTP id f25mr17993855pfn.45.1553415677582; Sun, 24 Mar 2019 01:21:17 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id e15sm15443314pgk.30.2019.03.24.01.21.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:16 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:12 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 01/20] diff-parseopt: convert --ws-error-highlight Date: Sun, 24 Mar 2019 15:19:55 +0700 Message-Id: <20190324082014.2041-2-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Mark one more string for translation while at there. Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/diff.c b/diff.c index ce118bb326..7bfdf08137 100644 --- a/diff.c +++ b/diff.c @@ -4801,17 +4801,18 @@ static void enable_patch_output(int *fmt) *fmt |= DIFF_FORMAT_PATCH; } -static int parse_ws_error_highlight_opt(struct diff_options *opt, const char *arg) +static int diff_opt_ws_error_highlight(const struct option *option, + const char *arg, int unset) { + struct diff_options *opt = option->value; int val = parse_ws_error_highlight(arg); - if (val < 0) { - error("unknown value after ws-error-highlight=%.*s", - -1 - val, arg); - return 0; - } + BUG_ON_OPT_NEG(unset); + if (val < 0) + return error(_("unknown value after ws-error-highlight=%.*s"), + -1 - val, arg); opt->ws_error_highlight = val; - return 1; + return 0; } static int parse_objfind_opt(struct diff_options *opt, const char *arg) @@ -5234,6 +5235,9 @@ static void prep_parse_options(struct diff_options *options) N_("show full pre- and post-image object names on the \"index\" lines")), OPT_COLOR_FLAG(0, "color", &options->use_color, N_("show colored diff")), + OPT_CALLBACK_F(0, "ws-error-highlight", options, N_(""), + N_("highlight whitespace errors in the 'context', 'old' or 'new' lines in the diff"), + PARSE_OPT_NONEG, diff_opt_ws_error_highlight), OPT_CALLBACK_F(0, "output-indicator-new", &options->output_indicators[OUTPUT_INDICATOR_NEW], N_(""), @@ -5397,9 +5401,7 @@ int diff_opt_parse(struct diff_options *options, if (cm & COLOR_MOVED_WS_ERROR) return -1; options->color_moved_ws_handling = cm; - } else if (skip_prefix(arg, "--ws-error-highlight=", &arg)) - return parse_ws_error_highlight_opt(options, arg); - else if (!strcmp(arg, "--ita-invisible-in-index")) + } else if (!strcmp(arg, "--ita-invisible-in-index")) options->ita_invisible_in_index = 1; else if (!strcmp(arg, "--ita-visible-in-index")) options->ita_invisible_in_index = 0; From patchwork Sun Mar 24 08:19:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B1B4922 for ; Sun, 24 Mar 2019 08:21:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AFC029829 for ; Sun, 24 Mar 2019 08:21:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F37D729830; Sun, 24 Mar 2019 08:21:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A76BE29829 for ; Sun, 24 Mar 2019 08:21:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728496AbfCXIVX (ORCPT ); Sun, 24 Mar 2019 04:21:23 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33223 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIVX (ORCPT ); Sun, 24 Mar 2019 04:21:23 -0400 Received: by mail-pg1-f193.google.com with SMTP id b12so4372834pgk.0 for ; Sun, 24 Mar 2019 01:21:22 -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=fQ9tNOoo1poOm1ZLmNviPon3/Jsxu8PatTIxAKaGdoU=; b=cX7PuwIYROXYN+79Y0SmP/jNvB/IqofJXKRK3/SCxwb8TyiO40JUvDwqiv4aGUBaqh DlwtRIV2ySah6CRuxVC/0YPQoGX0qmUFIoZvZL0zP0fPuVWJyfVZNAmb9F2xuiQQ912N shIAdM7Bzk7Eg18KhrObFD4VSKBuISJkdSsy9jkUnvwQyGy2+R+8KieJFrT6NrIj94hX 4S6aKFb5D4B2rWm+a3K3vuWe4TbfFQBJvQ99BjXFe2xel6E9zKZsvDFLJeP4dfMBxjtM FeksFkhlonC+wMmxFsExQw9tGbaTTKKnUNvqisVk2nNOc5si/V1jU0WHI8bkr64PFFJa 7W7g== 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=fQ9tNOoo1poOm1ZLmNviPon3/Jsxu8PatTIxAKaGdoU=; b=jzuUo9A9a0FUYn9IcPJHEdjMFnprYQyUCQPKjGhEbthOedk3aoSC4x2Ysqy+Wn3tXz vw1CXYTFempeRvPuOd7iTVZuCy10rWnvLn19JKTTFf3TA5tUxIz1q3yRb8LytWlJjAE/ 5K1hXK8zVA3/Cj/bBMqsO6FCd80ONPFeEewTQYbpPwSz0bHq8T38CrXfWcvtfNVdRbNL Q/G+ftGinS0ZBaUslQ9O3g/a+Eo7c5JxZ7tqIkZHhgsJ/eW2MNJcN2ccQleL4M6k03bF sDuCA6rxt541hmPhyyHxIFOzPA/j7L7lOWtqJO3ztVans3uGySwvj//w01cPgoM6lGhf afXw== X-Gm-Message-State: APjAAAWln3CbGWIDx1OsFUI34LSjGltbxGBmBMZEsFleUmxkVvXc0Ou4 74zCWL35NQenkSdRLhB2gmRs2mqH X-Google-Smtp-Source: APXvYqwbz9OB/Q5Dx/HkPlCH8fZ+Av4BW+/ec7TieMw3osTYq/gYyJunvoFOinPbO7MW/2pcRjGL/A== X-Received: by 2002:a62:58c7:: with SMTP id m190mr18106081pfb.4.1553415682534; Sun, 24 Mar 2019 01:21:22 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id y14sm16654754pgg.6.2019.03.24.01.21.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:21 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:17 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 02/20] diff-parseopt: convert --ita-[in]visible-in-index Date: Sun, 24 Mar 2019 15:19:56 +0700 Message-Id: <20190324082014.2041-3-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index 7bfdf08137..8255db6966 100644 --- a/diff.c +++ b/diff.c @@ -5352,6 +5352,12 @@ static void prep_parse_options(struct diff_options *options) N_("specify how differences in submodules are shown"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_submodule), + OPT_SET_INT_F(0, "ita-invisible-in-index", &options->ita_invisible_in_index, + N_("hide 'git add -N' entries from the index"), + 1, PARSE_OPT_NONEG), + OPT_SET_INT_F(0, "ita-visible-in-index", &options->ita_invisible_in_index, + N_("treat 'git add -N' entries as real in the index"), + 0, PARSE_OPT_NONEG), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, @@ -5401,10 +5407,7 @@ int diff_opt_parse(struct diff_options *options, if (cm & COLOR_MOVED_WS_ERROR) return -1; options->color_moved_ws_handling = cm; - } else if (!strcmp(arg, "--ita-invisible-in-index")) - options->ita_invisible_in_index = 1; - else if (!strcmp(arg, "--ita-visible-in-index")) - options->ita_invisible_in_index = 0; + } /* misc options */ else if (!strcmp(arg, "-z")) From patchwork Sun Mar 24 08:19:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 537B5922 for ; Sun, 24 Mar 2019 08:21:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4229529829 for ; Sun, 24 Mar 2019 08:21:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36A3A29830; Sun, 24 Mar 2019 08:21:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9E3329829 for ; Sun, 24 Mar 2019 08:21:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728509AbfCXIV2 (ORCPT ); Sun, 24 Mar 2019 04:21:28 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44215 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIV2 (ORCPT ); Sun, 24 Mar 2019 04:21:28 -0400 Received: by mail-pf1-f196.google.com with SMTP id a3so4278325pff.11 for ; Sun, 24 Mar 2019 01:21:27 -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=n8/8INEw9mXjh7augXRGK+u6W5dhTqMFJTxPb9iszv8=; b=vboFsmhhG6vVz+IubNZ82kBuZInfjhZI02n/upkp2szUeAnh87Mgnv2NDADhCZZxDY 4Ic0Jc6yWEAiqCa3DtylKhfBhPcUrMZtcfMh2h3DtxkeWgZ1tls+zsKRt5SBxbPPc4Y+ LvpZqVj6a1j5QYdQt33eTWBfXk1e1xbI+sDt41rqlVCgXYCHcuxnRMVLkHYcinzpUd/1 v62u0IClMd1tucoVjO7QgkC521Ne23ztQ3jKVIZEFpoYp3yk8dUukuv2YBMzVVcFjS9A CYAWX+14OblsGW0LiR80HkpY/FM4TYTTijNbT5JGflv6+LwNSNlOjHFHlZMMa+e6Y+OL 9lzQ== 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=n8/8INEw9mXjh7augXRGK+u6W5dhTqMFJTxPb9iszv8=; b=qKzShcG7PLoeUOD0GHiGPV7XuGl5wy20Bxg+gOZEEygoWPAm7go6ejS/Jg30Ay+i/R H9Pi/vL7mbLjKA7Ub9n6k/ogg1U+YlFJEJD7IZEcHm7EWha5Lr27oeoXkHENNz8brqn+ wKD8+Otnrkkw+VZV8eMGfSZVN6vQDpexdOz5f7PdEmnoWarAWpmBd9YTt6c9io3WcG7e 7YLsSOH6wK4Tt7R/B9abgW/rujEr3Z+VwzzlYt4twEbkTjp+ePE9uWkkcg0ScVw/mrez glBevGY7CM2kHuPkCqWAGQqvzkndK5t6Ryx/ZgB0gd/T70vyzlPxklSE+CO0ngdFErDj JNkg== X-Gm-Message-State: APjAAAXefgWLoF4+VIppdfrJtLU1iyjp0s8VeHHluUPxiMumQrFYrRiW 8idyUk7E4B25oK78Ff7af88= X-Google-Smtp-Source: APXvYqzYrtaUixiOxDmtzKFsk6ENfAGs7sfFZasNvIHlx4Lh/K3OLb4Ca6ru7G4HRRUrJKlrDcaAqg== X-Received: by 2002:a17:902:e3:: with SMTP id a90mr18365247pla.45.1553415687704; Sun, 24 Mar 2019 01:21:27 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id k83sm40750898pfj.178.2019.03.24.01.21.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:27 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:22 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 03/20] diff-parseopt: convert -z Date: Sun, 24 Mar 2019 15:19:57 +0700 Message-Id: <20190324082014.2041-4-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index 8255db6966..2b1d015553 100644 --- a/diff.c +++ b/diff.c @@ -5238,6 +5238,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "ws-error-highlight", options, N_(""), N_("highlight whitespace errors in the 'context', 'old' or 'new' lines in the diff"), PARSE_OPT_NONEG, diff_opt_ws_error_highlight), + OPT_SET_INT('z', NULL, &options->line_termination, + N_("do not munge pathnames and use NULs as output field terminators in --raw or --numstat"), + 0), OPT_CALLBACK_F(0, "output-indicator-new", &options->output_indicators[OUTPUT_INDICATOR_NEW], N_(""), @@ -5410,8 +5413,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if (!strcmp(arg, "-z")) - options->line_termination = 0; else if ((argcount = short_opt('l', av, &optarg))) { options->rename_limit = strtoul(optarg, NULL, 10); return argcount; From patchwork Sun Mar 24 08:19:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3723C1669 for ; Sun, 24 Mar 2019 08:21:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24A0429829 for ; Sun, 24 Mar 2019 08:21:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1785B29830; Sun, 24 Mar 2019 08:21:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B10C829829 for ; Sun, 24 Mar 2019 08:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728510AbfCXIVd (ORCPT ); Sun, 24 Mar 2019 04:21:33 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34025 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIVd (ORCPT ); Sun, 24 Mar 2019 04:21:33 -0400 Received: by mail-pg1-f194.google.com with SMTP id v12so4372614pgq.1 for ; Sun, 24 Mar 2019 01:21:33 -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=M9L/2RGzOOHTzLOJnp/cHexai2GyZ9XYITXOTJJoRIA=; b=e3pKFxS5p+Xzrjo88jdS8evncS26aKugLgb//2v1dBo2wBlM6xNXduZhwFQ7tyst39 lDdroYvWJh2fEt/Bh2MYW/0B8jFJL3iKNRizVFj/tl/OR2WfSEbV/HQjeMDYdrQfq2B3 PEhQMvw9mQrcKXwbL6rwN6qCwJp8W+vIygpE7BhUAMh7mu7Ml2CIvRwUPSCpop6SA7pB ylLX2Grhgi6AbrbiiueTzIJJztY7IbOyVTk0XlKKC6uE24BJsXcHvWSubqkk0NhthE4d qgWkAKHnSCfWYZ+ZBwJuIiukAV9XFg2i3aeh/VZH2cZxURoSPL9Z7NjEO/wbgIRCRnRw HR/Q== 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=M9L/2RGzOOHTzLOJnp/cHexai2GyZ9XYITXOTJJoRIA=; b=cetyO0tlmz131sDWMjBltLCZHtcv98fVcugLzcL01wsGgiIg6Mi5wG/ubxOs22McKd 0Oi8kj17JP8k70hCf/eyuq6rgPfj/8DIqN6lcshiIchIrbnvq7ouqHeDA89KKQNIJanF hr1yBAOWAjisCIKchhG2gMneDvOZi81FS3odkD3h/3a/xl1jH9xLNNTS82HI90P70g2S ala20N25g1NeYFUYw3Tki7nyio9Wsr2TFuXGWCv4eN8rEZHs6ICoMZexNLrY8MTIHRbG o1adR2S3qnqYLVbOskHJ1cwM0/gPB3DVre9WM/0mIlqcQ3PPDnMyszRzsmmtFJeptJcV tghw== X-Gm-Message-State: APjAAAXM3ebWCU2l4gHfxxzrbV5kZ2rVwlen4MdXobwaOBV/6YYxe1yt 2DF8GAMpaP7X2RfG4f8ne4c= X-Google-Smtp-Source: APXvYqxv+uY+IRsAXkW30Z1ZCq3nfXjzn+g+khVX+9ukBQhNNH3awXPX8pS0H1IbMmS1sNuKQfA84w== X-Received: by 2002:a63:cf0f:: with SMTP id j15mr17549387pgg.329.1553415692892; Sun, 24 Mar 2019 01:21:32 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id v19sm15273432pfa.138.2019.03.24.01.21.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:32 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:28 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 04/20] diff-parseopt: convert -l Date: Sun, 24 Mar 2019 15:19:58 +0700 Message-Id: <20190324082014.2041-5-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index 2b1d015553..6b19c97499 100644 --- a/diff.c +++ b/diff.c @@ -5283,6 +5283,8 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "follow", options, NULL, N_("continue listing the history of a file beyond renames"), PARSE_OPT_NOARG, diff_opt_follow), + OPT_INTEGER('l', NULL, &options->rename_limit, + N_("prevent rename/copy detection if the number of rename/copy targets exceeds given limit")), OPT_GROUP(N_("Diff algorithm options")), OPT_BIT(0, "minimal", &options->xdl_opts, @@ -5413,10 +5415,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if ((argcount = short_opt('l', av, &optarg))) { - options->rename_limit = strtoul(optarg, NULL, 10); - return argcount; - } else if ((argcount = short_opt('S', av, &optarg))) { options->pickaxe = optarg; options->pickaxe_opts |= DIFF_PICKAXE_KIND_S; From patchwork Sun Mar 24 08:19:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 357D7922 for ; Sun, 24 Mar 2019 08:21:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2367B29829 for ; Sun, 24 Mar 2019 08:21:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17E9D29830; Sun, 24 Mar 2019 08:21:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC0E629829 for ; Sun, 24 Mar 2019 08:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728511AbfCXIVj (ORCPT ); Sun, 24 Mar 2019 04:21:39 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33455 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIVj (ORCPT ); Sun, 24 Mar 2019 04:21:39 -0400 Received: by mail-pf1-f193.google.com with SMTP id i19so4314197pfd.0 for ; Sun, 24 Mar 2019 01:21:38 -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=/3OALaxX2xlmtRASBKEgcfP/yL0aPFxCvsxPlcT2m7Y=; b=oGAGvUSAs4lYf/SujZ2xWH03AlJmvtC0u534WEuyAGK4Y5p499cyPp6i05jabY/e49 SMZCZKXbzOxsYHdxoO7oKcJ94hzO43KtHODWlsYT7x2MJNQpbGxso4tN3GbYdEOGzjHj X70HCrMrMUwPJd7UznPI0BC4M3Q3QSdJxGZ5SiYiUVPTus6sDazs5XnJh59908nPNMJx SpPTMZT60PFxWJHJq7hQb/Yf97ZxSGAxUaxwzvw7RJdD+orIvyVPRchwxezvOpKFwGmH iUNrVs0YgBUOtP8cTOwEF9BjQV+SDN+eONst9mLbMqIUmBwOKONBm/e5QJ0Mxh2Ulm3b K9Hw== 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=/3OALaxX2xlmtRASBKEgcfP/yL0aPFxCvsxPlcT2m7Y=; b=B0O6rJ4a59I2gdDEDTePvLIj5V8oryZK4ET4Gxc1PoO6qY4WsYnUSKUo4Tb0NNBUfA PVQ3naaMJRNfYbLqtJP4qNRuGxsxMLjLltUPtA9EB6ORnztNsY/ewJiySBitVlOtEI9D ya9bSFyW0YKutetLXEJtDYlQH112IPcYT6yoa1HygBjInT8Lp3XCQ6P5XPjfqqdEcj2a YXRr3qKcy/cJhkF5OmQkqtrCZr/WsQBmE+rDYe1OQZFksG1weS5vjPJt2egi1z4NhZax 5LmgqlDuppopqIAReppigTmferUu8QWK6iushlOtax8epSEWt9vlN67wjT17K2LDR8Up wAlw== X-Gm-Message-State: APjAAAV4nZ/JBfJRl49rmG6gQp2wgzW7F4f+cUwjYXta8kLI3mHWkcVz 7hLDeysGjUSqYwGFHb+my2o= X-Google-Smtp-Source: APXvYqyCWzwFwUBv8wdLT5yG8GZB6evpl/drlZlrLPUm4+cj2fB3QJozRcbxrh8z5t6wQCVHQAXhuw== X-Received: by 2002:a62:1d8c:: with SMTP id d134mr18080232pfd.185.1553415698487; Sun, 24 Mar 2019 01:21:38 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id p3sm21083710pfp.136.2019.03.24.01.21.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:37 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:33 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 05/20] diff-parseopt: convert -S|-G Date: Sun, 24 Mar 2019 15:19:59 +0700 Message-Id: <20190324082014.2041-6-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/diff.c b/diff.c index 6b19c97499..8f01fbc2c1 100644 --- a/diff.c +++ b/diff.c @@ -5056,6 +5056,28 @@ static int diff_opt_patience(const struct option *opt, return 0; } +static int diff_opt_pickaxe_regex(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + options->pickaxe = arg; + options->pickaxe_opts |= DIFF_PICKAXE_KIND_G; + return 0; +} + +static int diff_opt_pickaxe_string(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + options->pickaxe = arg; + options->pickaxe_opts |= DIFF_PICKAXE_KIND_S; + return 0; +} + static int diff_opt_relative(const struct option *opt, const char *arg, int unset) { @@ -5363,6 +5385,12 @@ static void prep_parse_options(struct diff_options *options) OPT_SET_INT_F(0, "ita-visible-in-index", &options->ita_invisible_in_index, N_("treat 'git add -N' entries as real in the index"), 0, PARSE_OPT_NONEG), + OPT_CALLBACK_F('S', NULL, options, N_(""), + N_("look for differences that change the number of occurrences of the specified string"), + 0, diff_opt_pickaxe_string), + OPT_CALLBACK_F('G', NULL, options, N_(""), + N_("look for differences that change the number of occurrences of the specified regex"), + 0, diff_opt_pickaxe_regex), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, @@ -5415,15 +5443,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if ((argcount = short_opt('S', av, &optarg))) { - options->pickaxe = optarg; - options->pickaxe_opts |= DIFF_PICKAXE_KIND_S; - return argcount; - } else if ((argcount = short_opt('G', av, &optarg))) { - options->pickaxe = optarg; - options->pickaxe_opts |= DIFF_PICKAXE_KIND_G; - return argcount; - } else if (!strcmp(arg, "--pickaxe-all")) options->pickaxe_opts |= DIFF_PICKAXE_ALL; else if (!strcmp(arg, "--pickaxe-regex")) From patchwork Sun Mar 24 08:20:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31535922 for ; Sun, 24 Mar 2019 08:21:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20F9F29829 for ; Sun, 24 Mar 2019 08:21:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1290629830; Sun, 24 Mar 2019 08:21:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFA9329829 for ; Sun, 24 Mar 2019 08:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728531AbfCXIVo (ORCPT ); Sun, 24 Mar 2019 04:21:44 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35046 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIVo (ORCPT ); Sun, 24 Mar 2019 04:21:44 -0400 Received: by mail-pg1-f196.google.com with SMTP id g8so4363974pgf.2 for ; Sun, 24 Mar 2019 01:21:43 -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=iPqpPFaXEZAtaXXl1NlV+brp1RzRiSk31O39auBSgXo=; b=cVJl7LMex8qtZmJ6uEOU1IGJKknVlf1aLWOtrj3G8MSw3uIBgSFjz9Vlh+RRooN/Oj 7CAk/c4UHZjWK3B9Vj8wb55azneXIeVb4nIbFzAmCaFSBFW4DmhnlKvdYonC2DJ8T0BP rmmpowOzBG3xcg1LWEMNSX5cctGtQpZM8QwRwmjBIIZmscjdNEPVfo98rlBQElm929W2 zOuKTvENt2mvCq5fpAEWtpnucONoK23Yd0vHXgOfNNk+zCOZsvg9JvKzNKzdF2JFCj1r so5ZEkr+gCkPSqZ1uiGgmxzI3ahRf1L4daAqoZP+h/uienHZ95XXbaP6c7AWXUiyKxni HvuQ== 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=iPqpPFaXEZAtaXXl1NlV+brp1RzRiSk31O39auBSgXo=; b=XeHUt3JLc7eGH+dS+cURD1Gree2FYA03a4YNxtMon98YBGkQ5GLJh/3H/TEaxhwBP4 4O3hABvDuQnxB8HvTNtGPWg8PHyRJE99iAIaUoOo5QGwbwFtvrqUWSPeT84nvh2UOcVR S2BZE1WpPBYR+E0Pfu1WB9dn3Wf3vtklrxBQ+ijDK66Mlr/jGAx+2BTUCghUNUpuRcb/ R27BYdTuA2uehxH3YJQT/tB7zYogOhmf9hNz+/fgdaX3ijaP2dbGz5uU0I0BIntG7SSA W+roWR7DivwPp423n/ncVpjjrcwLE+luWUt7HgPP8dUwe5jVZwQd5HXbejtSC8PvH3by X81g== X-Gm-Message-State: APjAAAUbfvnJRH1xzfcTRs+Bs/TC0SEl1acKrq7cLEaqZIPZxIeSJF+E 5RXvvo08DuLEOGVAc6SdNuX5S7Nd X-Google-Smtp-Source: APXvYqx6HqoIZrFuOZHnqFYezPk4eLOpO8Jp8HFXzgXzC7DwFeTfxneoUjZiroHCOd72KHMyUhXU4w== X-Received: by 2002:a17:902:4101:: with SMTP id e1mr19330713pld.25.1553415703715; Sun, 24 Mar 2019 01:21:43 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id i79sm25621398pfj.28.2019.03.24.01.21.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:42 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:38 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 06/20] diff-parseopt: convert --pickaxe-all|--pickaxe-regex Date: Sun, 24 Mar 2019 15:20:00 +0700 Message-Id: <20190324082014.2041-7-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index 8f01fbc2c1..699f8605d0 100644 --- a/diff.c +++ b/diff.c @@ -5391,6 +5391,12 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F('G', NULL, options, N_(""), N_("look for differences that change the number of occurrences of the specified regex"), 0, diff_opt_pickaxe_regex), + OPT_BIT_F(0, "pickaxe-all", &options->pickaxe_opts, + N_("show all changes in the changeset with -S or -G"), + DIFF_PICKAXE_ALL, PARSE_OPT_NONEG), + OPT_BIT_F(0, "pickaxe-regex", &options->pickaxe_opts, + N_("treat in -S as extended POSIX regular expression"), + DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, @@ -5443,10 +5449,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if (!strcmp(arg, "--pickaxe-all")) - options->pickaxe_opts |= DIFF_PICKAXE_ALL; - else if (!strcmp(arg, "--pickaxe-regex")) - options->pickaxe_opts |= DIFF_PICKAXE_REGEX; else if ((argcount = short_opt('O', av, &optarg))) { options->orderfile = prefix_filename(prefix, optarg); return argcount; From patchwork Sun Mar 24 08:20:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 029C1922 for ; Sun, 24 Mar 2019 08:21:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E547329829 for ; Sun, 24 Mar 2019 08:21:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9CAD29830; Sun, 24 Mar 2019 08:21:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 836FD29829 for ; Sun, 24 Mar 2019 08:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728540AbfCXIVt (ORCPT ); Sun, 24 Mar 2019 04:21:49 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38220 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIVt (ORCPT ); Sun, 24 Mar 2019 04:21:49 -0400 Received: by mail-pf1-f193.google.com with SMTP id 10so4299628pfo.5 for ; Sun, 24 Mar 2019 01:21:49 -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=dzh3J9V9o03cihS3oPoLWWVcPoW/ZQfztAUdyR1NAYg=; b=IOOR2qkrfGRWkehZKMg1xlZLUkDHSpD80MA+E6NSvpfrmjw6wU//2HMPMpRehw0jkO yuWtRqhQlUDVqmAYc2MAkUaF5nyie5hRmLuXN/CbstuxNhW4Db9NuCDKM0pXUWMhrQqH +aD8h6PXc6ACIkkFboIFPEy67bevQhH1/SZkODb10BAu4TVGeR5A12hTmK8OUhmeJu+Y 1Q1hPc2aW6oIoNxjgQKGsO/2upNX8b4xRSQ49UlJMkBWlEpDoiOmI3tfGT4U+HaeBxFW 4rjZlh8l6P59hSz5/SmgXdL5j1TXU1tuTVMj9xwjl81OkRhLKvx3gibWhvAqP9987i8T Fsfg== 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=dzh3J9V9o03cihS3oPoLWWVcPoW/ZQfztAUdyR1NAYg=; b=HRZTwt22bSCxuPmG3A+6Nii0KDZQ1110KeUyMKXeGgU4TnDOTSUVLWVny4neYxEwyK 9Oz28rRqd+aVTOCUGsoemRLqVBKLbfgKLa9lo7juSjqtTrhpxUn4PkBTHYUS1ziMRWxM wvBDWXTLtP4ntuLHBIizq7wo7pVWCd+xaBY4yEOznnijLVh5ytMTT5fGP1aLqtulf1JH GAmYxxj1R66M4kcvn8OUavSy2hxmA4iyCXf50p2iLWHfLhIItaB54/MepMBffMN09DPu f24DsLfM//w3kcR/b2E8F/ICxnzGk88sDSkvsQHe9XKxKSg6wt4WyX1G6JfnmW+xqQ7V DTUA== X-Gm-Message-State: APjAAAVjnaCdmNtuDa7H7uiEuwEOrk2mJvLofnH1oOdSqxQFQKmSs1va azhCpjGQCDN2tfelZYyTQ/KWIB/Z X-Google-Smtp-Source: APXvYqxCIUez7ulIbtxlmrtAE4vN8Yp9UhO5DZw9JMUahKntamKDLaGEGU9N+8NwKmp7lQq8kBJHog== X-Received: by 2002:a17:902:2aca:: with SMTP id j68mr18916946plb.233.1553415708797; Sun, 24 Mar 2019 01:21:48 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id f3sm15228205pfn.100.2019.03.24.01.21.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:47 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:44 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 07/20] diff-parseopt: convert -O Date: Sun, 24 Mar 2019 15:20:01 +0700 Message-Id: <20190324082014.2041-8-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/diff.c b/diff.c index 699f8605d0..849620aea5 100644 --- a/diff.c +++ b/diff.c @@ -4617,22 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va return 1; } -static inline int short_opt(char opt, const char **argv, - const char **optarg) -{ - const char *arg = argv[0]; - if (arg[0] != '-' || arg[1] != opt) - return 0; - if (arg[2] != '\0') { - *optarg = arg + 2; - return 1; - } - if (!argv[1]) - die("Option '%c' requires a value", opt); - *optarg = argv[1]; - return 2; -} - int parse_long_opt(const char *opt, const char **argv, const char **optarg) { @@ -5397,6 +5381,8 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "pickaxe-regex", &options->pickaxe_opts, N_("treat in -S as extended POSIX regular expression"), DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG), + OPT_FILENAME('O', NULL, &options->orderfile, + N_("control the order in which files appear in the output")), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, @@ -5449,10 +5435,7 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if ((argcount = short_opt('O', av, &optarg))) { - options->orderfile = prefix_filename(prefix, optarg); - return argcount; - } else if (skip_prefix(arg, "--find-object=", &arg)) + else if (skip_prefix(arg, "--find-object=", &arg)) return parse_objfind_opt(options, arg); else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) { int offending = parse_diff_filter_opt(optarg, options); From patchwork Sun Mar 24 08:20:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9BB31669 for ; Sun, 24 Mar 2019 08:21:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B79E129829 for ; Sun, 24 Mar 2019 08:21:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABFFE29830; Sun, 24 Mar 2019 08:21:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5659129829 for ; Sun, 24 Mar 2019 08:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728545AbfCXIVz (ORCPT ); Sun, 24 Mar 2019 04:21:55 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46509 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIVy (ORCPT ); Sun, 24 Mar 2019 04:21:54 -0400 Received: by mail-pf1-f195.google.com with SMTP id 9so4275908pfj.13 for ; Sun, 24 Mar 2019 01:21:54 -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=fKleG4zI9mc9cJek5uFc0wtkcfCb73Qexrrf6GPCraM=; b=PnS7+7ttmWb90Vw8J1niBo6TCV2MGnJZkR7HjDN/ApLsQy7QDQ16SP5WzgipqD6uCq KoPj8NYe+EZDvHn0+mRmKkrH4+lJhZXgqcMbJYU3e7Am9CVGskkgpWjqEFoYlQdLWXaK Wh8iMSgZedwXmGfn1XYtqKKjY+TL8GEKZKuy6KFzeHdaIfb9XFuHSQsg+iWAl043FyXx +hrdY1zuNfCzuwVd0duZ1UW02Kus8EBm2V/2hgSpBHCTesTI4q/99gpTRMnTSn1Yc6j3 qrL5ztQt4MgtTuq2LSKn3y8/vqDLBsb/GXX8FE95HCUuCGg5AuFwoF+wTDJh7lkfWn1Q sthg== 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=fKleG4zI9mc9cJek5uFc0wtkcfCb73Qexrrf6GPCraM=; b=ji+tDTxSmx3xBBJD52AzhmCgyscXn1xUSUo7z75Ui/5hJX06r9T+uqXW+abGo6mPp/ TJamxydsVYnkbrWiyH3lEje7uHF6H7ZuKvtgZJPzMDBeTZ3NAZMKjiv9gu68w1doXI7Q vqmP2sKssu5PFWxzhInVFpmLVrsRVWYUnnbAmS1A2EcTEskLEu/6nbksub7th4z2zclH 0i/aDPJqICsb8Eu9kE03i1ZZVUdfabC0M2VCywPlXaHRoGqIbMzSlRcSrx5zVbBMpctl X9c7PUVv7xgqf3DD43rrQyEVuHavUH/rrGlg57X5eBmrCieBVLUNY8aqvWH/19VGPlsh 86aA== X-Gm-Message-State: APjAAAUCATytlnh6nHw/fJuGppMy2PrXbBcgbp2s4RzXpwCXGkKzDpyD sH6lb0rlJkcVooRVLJy69L0= X-Google-Smtp-Source: APXvYqwv1oQQj3pOiLbZ0smaXBu6dqivfeNtZ7uKPPKxYjqDn6d2JbcZe3pSfCpoYlTbEOqt7ItwDA== X-Received: by 2002:aa7:914f:: with SMTP id 15mr17962692pfi.49.1553415714170; Sun, 24 Mar 2019 01:21:54 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id l5sm21233491pfi.97.2019.03.24.01.21.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:53 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:49 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 08/20] diff-parseopt: convert --find-object Date: Sun, 24 Mar 2019 15:20:02 +0700 Message-Id: <20190324082014.2041-9-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While at it, mark one more string for translation. Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/diff.c b/diff.c index 849620aea5..99871d2546 100644 --- a/diff.c +++ b/diff.c @@ -4799,12 +4799,15 @@ static int diff_opt_ws_error_highlight(const struct option *option, return 0; } -static int parse_objfind_opt(struct diff_options *opt, const char *arg) +static int diff_opt_find_object(const struct option *option, + const char *arg, int unset) { + struct diff_options *opt = option->value; struct object_id oid; + BUG_ON_OPT_NEG(unset); if (get_oid(arg, &oid)) - return error("unable to resolve '%s'", arg); + return error(_("unable to resolve '%s'"), arg); if (!opt->objfind) opt->objfind = xcalloc(1, sizeof(*opt->objfind)); @@ -4813,7 +4816,7 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg) opt->flags.recursive = 1; opt->flags.tree_in_recursive = 1; oidset_insert(opt->objfind, &oid); - return 1; + return 0; } static int diff_opt_anchored(const struct option *opt, @@ -5383,6 +5386,9 @@ static void prep_parse_options(struct diff_options *options) DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG), OPT_FILENAME('O', NULL, &options->orderfile, N_("control the order in which files appear in the output")), + OPT_CALLBACK_F(0, "find-object", options, N_(""), + N_("look for differences that change the number of occurrences of the specified object"), + PARSE_OPT_NONEG, diff_opt_find_object), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, @@ -5435,8 +5441,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if (skip_prefix(arg, "--find-object=", &arg)) - return parse_objfind_opt(options, arg); else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) { int offending = parse_diff_filter_opt(optarg, options); if (offending) From patchwork Sun Mar 24 08:20:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 143011669 for ; Sun, 24 Mar 2019 08:22:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 010B829829 for ; Sun, 24 Mar 2019 08:22:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E96AD29830; Sun, 24 Mar 2019 08:22:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 822D529829 for ; Sun, 24 Mar 2019 08:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728550AbfCXIWA (ORCPT ); Sun, 24 Mar 2019 04:22:00 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43472 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIWA (ORCPT ); Sun, 24 Mar 2019 04:22:00 -0400 Received: by mail-pg1-f193.google.com with SMTP id l11so4335385pgq.10 for ; Sun, 24 Mar 2019 01:21:59 -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=19J41iR97i/mP6yPwyBsWOHUZPfo+bimifdbVSzfPJI=; b=Nn264d+LWt9qT++HtsIoI9XLz1LF8kvdgkApfFWe4JiLkzQAwTVt9I5YyM1PijIFXA pu6JRI1cUc9hz/FndULC8+qaPLGveUTCeOvQdBeire8dMoSNeB4FV1+uiJ3nL1nN9d4G mvSeT7hF675v2j5nE45wvfZx8X9OFTpYWulEyKXuN6s7a8nSpOgOUPNLPWa3pMciXNy3 2shWRgtiuIR6Ne0183qSfWS8FHMGrQrkH9RLsOVB2F5xEs2CRHAiVakBflYvhfxA8GAY vmnfoGDMQAh9jd9L8gg2koG3raj0sUFHJ6j1jNunGo2EaIGwMo3sPJ6c9lvCVzGCRZRv D/ug== 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=19J41iR97i/mP6yPwyBsWOHUZPfo+bimifdbVSzfPJI=; b=KzEGCnCWp8S0JYMYRflqdh2BIuWKtOadEe0Vyb13DeeXqOCvvzZFFDchPZ9IzJ+5ww BUr5ykm+MQe5XMnOM01Xck5SaGwaTrnlcBHcMqu9DX7LuPv7A7MbkPkST+f7EEYNVQBd dfdmkwp3TnL/LF4hluSTN3UxXQzRryM7lBSIx25Hq2fmGhLSRqTiNOZfye0HMTPPh/Fm qz2L4IFv8eyHqfOeCjOQlShJ4AHTePP8m0AvCDoZloA5RGES3Fo2aygLXCyuZ7FmP7v9 QNNE07Irrayf9cFPdjydGkM5vjhS/iyOzPo479Gke3jKU0ZVvzguWtZpZpODng3q+keV PdiA== X-Gm-Message-State: APjAAAXY7q4548pPUCmfeQksQ/jGUk8sScRKRNtELNbf/uS+G9bQ/bDF YmbnluxJuxUdb7GubG0lrqxenp95 X-Google-Smtp-Source: APXvYqzRM85Mcf5tZJHjixnBu+xwT3aYQyYnCZufyj+C8FSFEKKhKqx6fTSfjpgqKOqe+X7XcmCa6g== X-Received: by 2002:a63:fe0a:: with SMTP id p10mr13101503pgh.86.1553415719296; Sun, 24 Mar 2019 01:21:59 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id h19sm12967213pfd.130.2019.03.24.01.21.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:21:58 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:54 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 09/20] diff-parseopt: convert --diff-filter Date: Sun, 24 Mar 2019 15:20:03 +0700 Message-Id: <20190324082014.2041-10-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While at it, mark one more string for translation Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/diff.c b/diff.c index 99871d2546..47146c33f5 100644 --- a/diff.c +++ b/diff.c @@ -4736,10 +4736,13 @@ static unsigned filter_bit_tst(char status, const struct diff_options *opt) return opt->filter & filter_bit[(int) status]; } -static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt) +static int diff_opt_diff_filter(const struct option *option, + const char *optarg, int unset) { + struct diff_options *opt = option->value; int i, optch; + BUG_ON_OPT_NEG(unset); prepare_filter_bits(); /* @@ -4770,7 +4773,8 @@ static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt) bit = (0 <= optch && optch <= 'Z') ? filter_bit[optch] : 0; if (!bit) - return optarg[i]; + return error(_("unknown change class '%c' in --diff-filter=%s"), + optarg[i], optarg); if (negate) opt->filter &= ~bit; else @@ -5389,6 +5393,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "find-object", options, N_(""), N_("look for differences that change the number of occurrences of the specified object"), PARSE_OPT_NONEG, diff_opt_find_object), + OPT_CALLBACK_F(0, "diff-filter", options, N_("[(A|C|D|M|R|T|U|X|B)...[*]]"), + N_("select files by diff type"), + PARSE_OPT_NONEG, diff_opt_diff_filter), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, @@ -5441,13 +5448,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) { - int offending = parse_diff_filter_opt(optarg, options); - if (offending) - die("unknown change class '%c' in --diff-filter=%s", - offending, optarg); - return argcount; - } else if (!strcmp(arg, "--no-abbrev")) options->abbrev = 0; else if (!strcmp(arg, "--abbrev")) From patchwork Sun Mar 24 08:20:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC953922 for ; Sun, 24 Mar 2019 08:22:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8D2929829 for ; Sun, 24 Mar 2019 08:22:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD27229830; Sun, 24 Mar 2019 08:22:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7739629829 for ; Sun, 24 Mar 2019 08:22:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbfCXIWF (ORCPT ); Sun, 24 Mar 2019 04:22:05 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33273 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIWE (ORCPT ); Sun, 24 Mar 2019 04:22:04 -0400 Received: by mail-pg1-f194.google.com with SMTP id b12so4373434pgk.0 for ; Sun, 24 Mar 2019 01:22:04 -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=XqAkRTK77petW2yXkLM57yAG7ibs7weIzZdYYE8xx4M=; b=cPprRfKsURBaUOzRYuqD/lOnavdUiCIG5wfaYbORlXKPIPrNQ/v1O+xq+NUax2LnPZ 2V2DUzjxjiYgbq6oaopbWwDK2Bs8X9WPAdqfqwyKTWA6gwzULiVMbZbcK4vv8/dlkTIF b3lcZhSfRULBQlzSp71dA/UwzvRbxmTaNfg4uKryFXClRggLnXfpg9ihb9olhoB190v7 XLW0VZQ4XrSoL+/KsuLTIBGFEcDDYPoA45eOzXd8BurxF8MHDi3KaAKAdqRqjuYN3wIg bGZ3DiSoevB6tf9w8+1JarIfT4gn9RM0pFmccSxqcTDGMAZ+Vbs0m6g1n07MCujg9cbz GsKg== 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=XqAkRTK77petW2yXkLM57yAG7ibs7weIzZdYYE8xx4M=; b=aoMCA2tVZrDK/JL1XtN+nFhHDoQY6+/iZ2feOeAnAmA8mUG1t3yk1uU7FwE+CoSlJA 9i5styvgNqqUg8UJeOJWbKC0GUGeW7WXYdO14s0NKQxtpPL3HP+qw9VJ0ktXHepJSqUa vS9juD1Gr6qlf0I0NBVXe2vPsqwRj06fQzMpa/TN4+7T6Hf4RuxXabSAjZsjttTfwjTn Hp+vXSG+NJE2F0hHdJ3Gt8D0LQW1Qo/rEylHmrPYxH46oGtQBoNKFk/W9gZiM/9X7diq Gr2mYl2RaP6iVoWRoCVMLReJa9qXl+GzlHvQ+W2Lj+4xiLrhCmBMty43SuDWVY9UXKiO ogUg== X-Gm-Message-State: APjAAAWv5I9b40n+8DIG2r+jwQbUa+UJPc4ssxVIV5dolTnVAOiWSmPB xFIEOjGTIUPZwXC0rsZHBJr9YEf3 X-Google-Smtp-Source: APXvYqwyb4hWD669IQaaNRrZ2XHUu1/A5VL1wjhILgucKFeXOViIsRMVbJem2mMnRJnsVgQhH+UBqg== X-Received: by 2002:a17:902:b418:: with SMTP id x24mr12555459plr.323.1553415724408; Sun, 24 Mar 2019 01:22:04 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id z124sm31429636pfb.150.2019.03.24.01.22.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:03 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:21:59 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 10/20] diff-parseopt: convert --[no-]abbrev Date: Sun, 24 Mar 2019 15:20:04 +0700 Message-Id: <20190324082014.2041-11-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP OPT__ABBREV() has the same behavior as the deleted code with one difference: it does check for valid number and error out if not. And the '40' change is self explanatory. Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 12 +----------- parse-options-cb.c | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/diff.c b/diff.c index 47146c33f5..8d387280a4 100644 --- a/diff.c +++ b/diff.c @@ -5254,6 +5254,7 @@ static void prep_parse_options(struct diff_options *options) OPT_SET_INT('z', NULL, &options->line_termination, N_("do not munge pathnames and use NULs as output field terminators in --raw or --numstat"), 0), + OPT__ABBREV(&options->abbrev), OPT_CALLBACK_F(0, "output-indicator-new", &options->output_indicators[OUTPUT_INDICATOR_NEW], N_(""), @@ -5448,17 +5449,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if (!strcmp(arg, "--no-abbrev")) - options->abbrev = 0; - else if (!strcmp(arg, "--abbrev")) - options->abbrev = DEFAULT_ABBREV; - else if (skip_prefix(arg, "--abbrev=", &arg)) { - options->abbrev = strtoul(arg, NULL, 10); - if (options->abbrev < MINIMUM_ABBREV) - options->abbrev = MINIMUM_ABBREV; - else if (the_hash_algo->hexsz < options->abbrev) - options->abbrev = the_hash_algo->hexsz; - } else if ((argcount = parse_long_opt("src-prefix", av, &optarg))) { options->a_prefix = optarg; return argcount; diff --git a/parse-options-cb.c b/parse-options-cb.c index 2733393546..6e2e8d6273 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -22,8 +22,8 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) opt->long_name); if (v && v < MINIMUM_ABBREV) v = MINIMUM_ABBREV; - else if (v > 40) - v = 40; + else if (v > the_hash_algo->hexsz) + v = the_hash_algo->hexsz; } *(int *)(opt->value) = v; return 0; From patchwork Sun Mar 24 08:20:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0E421669 for ; Sun, 24 Mar 2019 08:22:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E67329829 for ; Sun, 24 Mar 2019 08:22:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9230C29830; Sun, 24 Mar 2019 08:22:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3174729829 for ; Sun, 24 Mar 2019 08:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728553AbfCXIWK (ORCPT ); Sun, 24 Mar 2019 04:22:10 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46063 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIWK (ORCPT ); Sun, 24 Mar 2019 04:22:10 -0400 Received: by mail-pg1-f193.google.com with SMTP id y3so4328826pgk.12 for ; Sun, 24 Mar 2019 01:22:09 -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=qb+Rp+f17CiNbmRmHci80PJN7cSdyo678ROTIJah4gY=; b=FAWKkCXo22l06UTlShHydT+ROv/NhTg2qMdTI2x9TDQzgULP9/BMHp0O3Lx9GdLhUE xcSeh4uFSOhCvU6qFKexPZrR/l3ddW0B628hueuzCDlNABeuRUSRasywFaB3NiHscfSb nWZ2BgWUHEErk0Rsvk4eauO77zua8rV9XynZOerZ7i2PV8UMcGI9+y6nq4hF4uld753G kse+a1igoWbBCuTNCdu2T6MOtRk8bDM2tVViLoVznpxGlHba7QH6evIXKqAiblSPUTIM 2JLz90FsgHPac82SseLNA9y9eXZ5yt6a4gCMux0fRVvzib/EninT28MixC5xhTXcGNiC 2cIA== 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=qb+Rp+f17CiNbmRmHci80PJN7cSdyo678ROTIJah4gY=; b=FNZCpTl+Gsh5wuUvMUAHcMolBeFq1lSqVhiGnKlcPZH7Oq7U/RFcGbEskzWKDP4k4a 8lzYOrfFeJI3WJ+B0deDrecUECwrbnSiRRgix5b985E9YrwbM/PrVtAAbsTgg2GbHUJ9 wFfkIWy80NpzvpLcnjRqyPCGJ7xHXUiA2QIt/g0KzG0o0we7sjtqOLtO7NF96w/KAr0M tijnNg2CCjJHdmvECOk2w7MWrTQyRvaKEn+Ln4Stcbfc7xENTT5R25bUK80GI8YzTQuW arJ46P1mX9Y7R0He4DZ0N2KAgXl7FCrg8PhWDytQZ126+r3n/gSg/yEO01yjPsay6hCN RZvw== X-Gm-Message-State: APjAAAXOP1gdA6enLaSfIDpS1IgkupnONcdm2Odd+PwCRLSgicVyXTRv 8DcBVdZmnQJECqdI9rY5XW0= X-Google-Smtp-Source: APXvYqxL0iB+91wRTKAr41K8ogdQBAgbgcTwYm/J87Ue7/yp/5zjmDFkdr+Ng9snrHMEb+8DGo7uGA== X-Received: by 2002:a62:2e07:: with SMTP id u7mr17705206pfu.176.1553415729416; Sun, 24 Mar 2019 01:22:09 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id o3sm14484133pgv.50.2019.03.24.01.22.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:08 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:04 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 11/20] diff-parseopt: convert --[src|dst]-prefix Date: Sun, 24 Mar 2019 15:20:05 +0700 Message-Id: <20190324082014.2041-12-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 14 ++++++-------- parse-options.h | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/diff.c b/diff.c index 8d387280a4..574fc511ff 100644 --- a/diff.c +++ b/diff.c @@ -5255,6 +5255,12 @@ static void prep_parse_options(struct diff_options *options) N_("do not munge pathnames and use NULs as output field terminators in --raw or --numstat"), 0), OPT__ABBREV(&options->abbrev), + OPT_STRING_F(0, "src-prefix", &options->a_prefix, N_(""), + N_("show the given source prefix instead of \"a/\""), + PARSE_OPT_NONEG), + OPT_STRING_F(0, "dst-prefix", &options->b_prefix, N_(""), + N_("show the given source prefix instead of \"b/\""), + PARSE_OPT_NONEG), OPT_CALLBACK_F(0, "output-indicator-new", &options->output_indicators[OUTPUT_INDICATOR_NEW], N_(""), @@ -5449,20 +5455,12 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if ((argcount = parse_long_opt("src-prefix", av, &optarg))) { - options->a_prefix = optarg; - return argcount; - } else if ((argcount = parse_long_opt("line-prefix", av, &optarg))) { options->line_prefix = optarg; options->line_prefix_length = strlen(options->line_prefix); graph_setup_line_prefix(options); return argcount; } - else if ((argcount = parse_long_opt("dst-prefix", av, &optarg))) { - options->b_prefix = optarg; - return argcount; - } else if (!strcmp(arg, "--no-prefix")) options->a_prefix = options->b_prefix = ""; else if (opt_arg(arg, '\0', "inter-hunk-context", diff --git a/parse-options.h b/parse-options.h index 7d83e2971d..c95cbe26f0 100644 --- a/parse-options.h +++ b/parse-options.h @@ -136,6 +136,7 @@ struct option { #define OPT_BOOL_F(s, l, v, h, f) OPT_SET_INT_F(s, l, v, h, 1, f) #define OPT_CALLBACK_F(s, l, v, a, h, f, cb) \ { OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), (cb) } +#define OPT_STRING_F(s, l, v, a, h, f) { OPTION_STRING, (s), (l), (v), (a), (h), (f) } #define OPT_END() { OPTION_END } #define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, \ @@ -157,7 +158,7 @@ struct option { #define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h) } #define OPT_MAGNITUDE(s, l, v, h) { OPTION_MAGNITUDE, (s), (l), (v), \ N_("n"), (h), PARSE_OPT_NONEG } -#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) } +#define OPT_STRING(s, l, v, a, h) OPT_STRING_F(s, l, v, a, h, 0) #define OPT_STRING_LIST(s, l, v, a, h) \ { OPTION_CALLBACK, (s), (l), (v), (a), \ (h), 0, &parse_opt_string_list } From patchwork Sun Mar 24 08:20:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6C931669 for ; Sun, 24 Mar 2019 08:22:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5CD629829 for ; Sun, 24 Mar 2019 08:22:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A4D229830; Sun, 24 Mar 2019 08:22:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44F4329829 for ; Sun, 24 Mar 2019 08:22:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728579AbfCXIWP (ORCPT ); Sun, 24 Mar 2019 04:22:15 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34069 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfCXIWP (ORCPT ); Sun, 24 Mar 2019 04:22:15 -0400 Received: by mail-pg1-f193.google.com with SMTP id v12so4373145pgq.1 for ; Sun, 24 Mar 2019 01:22:14 -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=SyB9w5DiUlYAJ/xuAkWi2w4PhWQCA1weyTbmvD+Hnbk=; b=gm3Sn5GGF+zVdQEQ6N/6JYTi/4Vzl+Dhwbx1b3dgeWimIIjG9xsiwM433z7iWCYNkn Rw+tnJqFD37iHNjCTJxBvV7WS1gYTdKl/Moh8t/p/w3/w17KQ0ky/e9fY+sp3jAGUsKT m/aj82JE9hivpLKVzjLwg3tB6vIMcSwd/UHNPwffenXemC+Xq6M5v3hBI1N5YL2rM208 eNi8OJ2OAeEGR6u27TZqB2vNXjIqw8xKlhmZ3JafNqAGVAaAzEaIrGlos0H6IKgipCD8 ELU6rEofiC+yZ7GrjP9MtYFhlSTPoHhArItGB0z1EbnBt9qPwQeo8/DJIbarsdmC14WC Dfbw== 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=SyB9w5DiUlYAJ/xuAkWi2w4PhWQCA1weyTbmvD+Hnbk=; b=AKdxJ93fHi0npqGKYY+/SZtE7ppvKwfaudgzAMlkkta5HxQ26iKO8DHaSIePTgWUlD GHmeIunGVTpWzLBoOMHMkHdHPelWgV/mE7NVpBUBpMJkO3cVU7xxmpaAGS/nnW/PztM2 h9ntnI+B04MbwreekRjkf0RSNhVHQUhj5aGBmCO+6S2KTOWSlZmPNgROKNDHO1lxB3DD Nub8RGRRd0wlovmn51Y4KPnE3lCsw2mLJYaAhdI0Z0/QFuYINcOSX/BV3lcn64FPWK2Z VVLEKlUI9Wyj6gsx3y2fr4BOsw0v0h277Juybd3a/nqKBOMXvZhdyhQRn5x63Qf7BQ7U RDkg== X-Gm-Message-State: APjAAAUcsdKCEFSBmHR/1K88qZ7vIMoKr5DPJduf1SgI2aLPxkqWH/Zg sWArzRQ98w9bSp3g0gXM79R8xcvG X-Google-Smtp-Source: APXvYqyRkWQQW2+LIBBER1sXZaMQ2qiiqrA65XIl47tYbwwrnML3pvakGeILM7OGA/4jDXQZKSO4kg== X-Received: by 2002:a65:6299:: with SMTP id f25mr17773892pgv.376.1553415734394; Sun, 24 Mar 2019 01:22:14 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id 17sm17604497pgt.0.2019.03.24.01.22.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:13 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:09 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 12/20] diff-parseopt: convert --line-prefix Date: Sun, 24 Mar 2019 15:20:06 +0700 Message-Id: <20190324082014.2041-13-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/diff.c b/diff.c index 574fc511ff..e1675a32ec 100644 --- a/diff.c +++ b/diff.c @@ -5010,6 +5010,18 @@ static int diff_opt_ignore_submodules(const struct option *opt, return 0; } +static int diff_opt_line_prefix(const struct option *opt, + const char *optarg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + options->line_prefix = optarg; + options->line_prefix_length = strlen(options->line_prefix); + graph_setup_line_prefix(options); + return 0; +} + static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx, const struct option *opt, const char *arg, int unset) @@ -5261,6 +5273,9 @@ static void prep_parse_options(struct diff_options *options) OPT_STRING_F(0, "dst-prefix", &options->b_prefix, N_(""), N_("show the given source prefix instead of \"b/\""), PARSE_OPT_NONEG), + OPT_CALLBACK_F(0, "line-prefix", options, N_(""), + N_("prepend an additional prefix to every line of output"), + PARSE_OPT_NONEG, diff_opt_line_prefix), OPT_CALLBACK_F(0, "output-indicator-new", &options->output_indicators[OUTPUT_INDICATOR_NEW], N_(""), @@ -5418,8 +5433,6 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac, const char *prefix) { const char *arg = av[0]; - const char *optarg; - int argcount; if (!prefix) prefix = ""; @@ -5455,12 +5468,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if ((argcount = parse_long_opt("line-prefix", av, &optarg))) { - options->line_prefix = optarg; - options->line_prefix_length = strlen(options->line_prefix); - graph_setup_line_prefix(options); - return argcount; - } else if (!strcmp(arg, "--no-prefix")) options->a_prefix = options->b_prefix = ""; else if (opt_arg(arg, '\0', "inter-hunk-context", From patchwork Sun Mar 24 08:20:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EAFB922 for ; Sun, 24 Mar 2019 08:22:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DE8029829 for ; Sun, 24 Mar 2019 08:22:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6258C29830; Sun, 24 Mar 2019 08:22:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FE3E29829 for ; Sun, 24 Mar 2019 08:22:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728591AbfCXIWU (ORCPT ); Sun, 24 Mar 2019 04:22:20 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41254 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728584AbfCXIWU (ORCPT ); Sun, 24 Mar 2019 04:22:20 -0400 Received: by mail-pg1-f196.google.com with SMTP id f6so214418pgs.8 for ; Sun, 24 Mar 2019 01:22:20 -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=RAZ4lU4VS6onT32ICpXGiDN7qpcHvJbVhIMOiQklC+A=; b=ORz+u2TY2pZa6ufgaONzAPG0/WMkqvjqYCLgxrxJJ33ps3xm4nA8wj+sQLC6fNsZx9 Syi2xySGqOz7OxDPNt4qsSfe+hO6JFJKlypbUKfVceXTglVTvRazTCL6DHqWUok698Ut CeYrx4DzBlto/vSpYrBHDWxkVO7vffQpPh/HpjkXj+FXVAbl+ST6T3nnaRXxQRZ0mCBY 8ESUui9/oM6GKbtXV2zXASKqvofYtWWnm72hn6Eij7omoH632Qx4N/ZMWMTzGCiVwy+Y DIHI4AGqcGwi+Ng0uC2YaMk7i7Qe5l5RIhntdMSvb7cvbdTyUocRTlbzMxyorXl+fAAl mcfA== 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=RAZ4lU4VS6onT32ICpXGiDN7qpcHvJbVhIMOiQklC+A=; b=UVWfyuk+0I+9HAw75p+EvNG0UaGrx8lxGtFqeE7O/K2A/Xn8uig6FurjbV3mdnB0Ya JEkH9bQUruqfjNNp1PGWPQrh7Kd6wHn3YEBZ8lW+vIsPLYVJvoHiVTav/6Zn02OgMkmw P3HKM322lFaiXZcuXfK6UqZsdFTTfFcXCBGDHI36HYFGTQJt+Oc4tEYHJD0a0vdrzpqQ wadodjKhKSkuZ7h7MI/QL6NQZAuGcx3tI65CgVzI0XYLwi4sgGQq7zEezuludvOtv3iJ KD3lVFs+rFYqtHF4/ImDr/qrTODmIXzFdZS+OBBP9hOFXdduQPIFMu1djOVWoixmV8pV RyuQ== X-Gm-Message-State: APjAAAXVJMjZx3FFUzBqndTDiOHLReLofwT1xrfVHbtGDpmFLJXSTpDs 66BGEKu8yLgu1r37oifv31g= X-Google-Smtp-Source: APXvYqwDwZjKdAGS402QjoPri9EqyLmXTT0ZTOKLjQT5yuymEmDXTzs+BCNRwbar3h3vBlJaYt+LMA== X-Received: by 2002:a63:1cd:: with SMTP id 196mr17582071pgb.58.1553415740055; Sun, 24 Mar 2019 01:22:20 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id f192sm21762509pfc.180.2019.03.24.01.22.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:19 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:14 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 13/20] diff-parseopt: convert --no-prefix Date: Sun, 24 Mar 2019 15:20:07 +0700 Message-Id: <20190324082014.2041-14-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index e1675a32ec..6029f8de2d 100644 --- a/diff.c +++ b/diff.c @@ -5022,6 +5022,18 @@ static int diff_opt_line_prefix(const struct option *opt, return 0; } +static int diff_opt_no_prefix(const struct option *opt, + const char *optarg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(optarg); + options->a_prefix = ""; + options->b_prefix = ""; + return 0; +} + static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx, const struct option *opt, const char *arg, int unset) @@ -5276,6 +5288,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "line-prefix", options, N_(""), N_("prepend an additional prefix to every line of output"), PARSE_OPT_NONEG, diff_opt_line_prefix), + OPT_CALLBACK_F(0, "no-prefix", options, NULL, + N_("do not show any source or destination prefix"), + PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_no_prefix), OPT_CALLBACK_F(0, "output-indicator-new", &options->output_indicators[OUTPUT_INDICATOR_NEW], N_(""), @@ -5468,8 +5483,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if (!strcmp(arg, "--no-prefix")) - options->a_prefix = options->b_prefix = ""; else if (opt_arg(arg, '\0', "inter-hunk-context", &options->interhunkcontext)) ; From patchwork Sun Mar 24 08:20:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE2EF922 for ; Sun, 24 Mar 2019 08:22:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD97129829 for ; Sun, 24 Mar 2019 08:22:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1E4829830; Sun, 24 Mar 2019 08:22:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34B9D29829 for ; Sun, 24 Mar 2019 08:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728592AbfCXIW0 (ORCPT ); Sun, 24 Mar 2019 04:22:26 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42112 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbfCXIWZ (ORCPT ); Sun, 24 Mar 2019 04:22:25 -0400 Received: by mail-pg1-f194.google.com with SMTP id p6so4343809pgh.9 for ; Sun, 24 Mar 2019 01:22:25 -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=kQKJyX6pIH0h0o6032BfFprRW4OqddV5C8R6Ngys9K8=; b=LskJUeY3xY4H4j1PazxvSH0ex6Q4oRwab/4EpYykF6ycsdlNRNA8on8Iaj2MGjRkoG fSQ85rc5TyYpdiBT7NPX9+pjSeSyTngrTmc+RvyQsuRC3i0Hgxu8NgyPr/7kpDlzNewu ASi8b1gNT3jEPQapNnjnt4+mV/eCPE7yxbTLf/FHqfZk4aLYaHUyAEiATnKocaxmgewY hlsg8LU/mrivLWvlRIQ5l9pR+Ten2sUjjFxzgKL478hljfqaxe49ZhkoOsGefM8JYTeQ hcYyXVfJt24fNqq5oShbEyHGqvAIbRdmBF8U4ExV8tM2JPNonrRbaXC5fIohRR7xbHvS UUNg== 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=kQKJyX6pIH0h0o6032BfFprRW4OqddV5C8R6Ngys9K8=; b=ps+WUjTzl8nd3CTl7c1abCP7An3JAh19AeCrGD3pGnlWbREv3UWrOzMpT2swPgrDof 8d4o6CqbOZBeBSYxoBt6YhHlxk0TKc+3d/+KwLnWcAy9nWWKraaTKpGim5H9U342tzJd KTELlt8CHcufYp+9nuVenxPvrFrWVoHENSowLM7Ru/x7YuZsLwkE3LyoajVbJaJbjJYV BZly7Qa8gGCCsNeK4pTGR0cqXRERiqAPfekOMTGAvLpmhJTLEAMzNuHgTDQ1LLVw0PFE bPfEMv3NMQBOfRVMBdvwiSjJscRc8YZ3gF6tr1ScgvbIMyj6GPkCDAgfqVoHRD28eJpx +JRQ== X-Gm-Message-State: APjAAAXzgRfj8oA9+F7kpt1ExRE0i8NPCWSmdzGCc3rLSTKEEG5hdSSA lkwQsUHM0QxnAPL15tzSZSQ= X-Google-Smtp-Source: APXvYqwBYiJc9Q/+8bMCNyBSpuaf3/pcXZEjBghztlSejrAms4rYn+lpITEXamxCf9VOvASDTiaXGA== X-Received: by 2002:a62:1197:: with SMTP id 23mr17996321pfr.210.1553415745243; Sun, 24 Mar 2019 01:22:25 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id i13sm14785369pgq.17.2019.03.24.01.22.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:24 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:20 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 14/20] diff-parseopt: convert --inter-hunk-context Date: Sun, 24 Mar 2019 15:20:08 +0700 Message-Id: <20190324082014.2041-15-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 50 +++---------------------------------------------- parse-options.h | 3 ++- 2 files changed, 5 insertions(+), 48 deletions(-) diff --git a/diff.c b/diff.c index 6029f8de2d..8b65b03c0d 100644 --- a/diff.c +++ b/diff.c @@ -4573,50 +4573,6 @@ void diff_setup_done(struct diff_options *options) FREE_AND_NULL(options->parseopts); } -static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val) -{ - char c, *eq; - int len; - - if (*arg != '-') - return 0; - c = *++arg; - if (!c) - return 0; - if (c == arg_short) { - c = *++arg; - if (!c) - return 1; - if (val && isdigit(c)) { - char *end; - int n = strtoul(arg, &end, 10); - if (*end) - return 0; - *val = n; - return 1; - } - return 0; - } - if (c != '-') - return 0; - arg++; - eq = strchrnul(arg, '='); - len = eq - arg; - if (!len || strncmp(arg, arg_long, len)) - return 0; - if (*eq) { - int n; - char *end; - if (!isdigit(*++eq)) - return 0; - n = strtoul(eq, &end, 10); - if (*end) - return 0; - *val = n; - } - return 1; -} - int parse_long_opt(const char *opt, const char **argv, const char **optarg) { @@ -5291,6 +5247,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "no-prefix", options, NULL, N_("do not show any source or destination prefix"), PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_no_prefix), + OPT_INTEGER_F(0, "inter-hunk-context", &options->interhunkcontext, + N_("show context between diff hunks up to the specified number of lines"), + PARSE_OPT_NONEG), OPT_CALLBACK_F(0, "output-indicator-new", &options->output_indicators[OUTPUT_INDICATOR_NEW], N_(""), @@ -5483,9 +5442,6 @@ int diff_opt_parse(struct diff_options *options, } /* misc options */ - else if (opt_arg(arg, '\0', "inter-hunk-context", - &options->interhunkcontext)) - ; else return 0; return 1; diff --git a/parse-options.h b/parse-options.h index c95cbe26f0..cca64d04cb 100644 --- a/parse-options.h +++ b/parse-options.h @@ -137,6 +137,7 @@ struct option { #define OPT_CALLBACK_F(s, l, v, a, h, f, cb) \ { OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), (cb) } #define OPT_STRING_F(s, l, v, a, h, f) { OPTION_STRING, (s), (l), (v), (a), (h), (f) } +#define OPT_INTEGER_F(s, l, v, h, f) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h), (f) } #define OPT_END() { OPTION_END } #define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, \ @@ -155,7 +156,7 @@ struct option { (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1} #define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \ (h), PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (i) } -#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h) } +#define OPT_INTEGER(s, l, v, h) OPT_INTEGER_F(s, l, v, h, 0) #define OPT_MAGNITUDE(s, l, v, h) { OPTION_MAGNITUDE, (s), (l), (v), \ N_("n"), (h), PARSE_OPT_NONEG } #define OPT_STRING(s, l, v, a, h) OPT_STRING_F(s, l, v, a, h, 0) From patchwork Sun Mar 24 08:20:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84E001669 for ; Sun, 24 Mar 2019 08:22:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74FAE29829 for ; Sun, 24 Mar 2019 08:22:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6951129830; Sun, 24 Mar 2019 08:22:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A93029829 for ; Sun, 24 Mar 2019 08:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbfCXIWb (ORCPT ); Sun, 24 Mar 2019 04:22:31 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33299 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbfCXIWa (ORCPT ); Sun, 24 Mar 2019 04:22:30 -0400 Received: by mail-pg1-f195.google.com with SMTP id b12so4373772pgk.0 for ; Sun, 24 Mar 2019 01:22:30 -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=E5OGSNhAK2KrRTTWxJ9pmfnCb1piWwcRC0MVDFL4CAI=; b=P98hGqwEW8RupKLhppWOqOmI2tRTss7HzsSOaBbxgMCDFy1drDhDeB8gOLQo4p6K9W /bjtt5LZ2kI1eQ89jBWr0NmPxJPSc1Q/3BovbYtqvmpfgbONj6yKUesz8nTULZ+R02EV 6gBUlOrBsBAKBnOeyytEfhr55VjOnlPEzDOjEEcnepQda7UfG56YbcLWyomfMJmESHO6 lxIlz9foX/fMOQUt6LMq8KuOCx1XGc978RSSa9SVu6Dd3DbTKrqt5rO0/7UcVfHqg/ez uCegCYq0HQUo5mPDjB1EMstJ98YUkg7nI4VhnLjioBX7/KOW58bYWyXwxrYW/ED548Lb W+/g== 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=E5OGSNhAK2KrRTTWxJ9pmfnCb1piWwcRC0MVDFL4CAI=; b=r9qGhXu5t5javOqypJDx1w0ykiwDFVwDInir4cxmoTS/ilNUq/6q7680H8nIGnLYOT sajj64Kk6pUYFLtbQYR3p3lSQeAj62EivINQpGH6k9nglDKZb/s9i1c/KGopqSwocIdu IQNaRs4anE/8T65xUbD3xvVgUJK962Mogyq39XatPF1ipch4e2GIXte1u/J+1+DDH6pz Lhnot6HQnPMaDZNogKsg8XZbE8fiVycNbNpUEJdLUJOWVNi9N77uWH7gNdu60ANW/iFP UUXC3bHiSGwCBDaLKPDkhaoOgla2UWlKsi8ckNU8arZptOA0Hgia8n0ABMrjgDYn9tcS JKsA== X-Gm-Message-State: APjAAAVJGReD3HVbrWHpuWTOMU8rBGd6uc9mz5xw9+FXhJnGfQL9In0u QWYnn16OQSdTDpWOIfLqBNaOBP/+ X-Google-Smtp-Source: APXvYqyYnD15lRksi0oz2HOTyJBPnaqHn+KVfWBkkMYBN7Lch4+UPeBx6qo867ZT1zyqLobiSJIAGg== X-Received: by 2002:a63:544f:: with SMTP id e15mr17838053pgm.344.1553415750267; Sun, 24 Mar 2019 01:22:30 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id h65sm15573313pgc.93.2019.03.24.01.22.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:29 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:25 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 15/20] diff-parseopt: convert --[no-]color-moved Date: Sun, 24 Mar 2019 15:20:09 +0700 Message-Id: <20190324082014.2041-16-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Mark one more string for translation while at there Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/diff.c b/diff.c index 8b65b03c0d..de6c09e95a 100644 --- a/diff.c +++ b/diff.c @@ -4841,6 +4841,27 @@ static int diff_opt_char(const struct option *opt, return 0; } +static int diff_opt_color_moved(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + if (unset) { + options->color_moved = COLOR_MOVED_NO; + } else if (!arg) { + if (diff_color_moved_default) + options->color_moved = diff_color_moved_default; + if (options->color_moved == COLOR_MOVED_NO) + options->color_moved = COLOR_MOVED_DEFAULT; + } else { + int cm = parse_color_moved(arg); + if (cm < 0) + return error(_("bad --color-moved argument: %s"), arg); + options->color_moved = cm; + } + return 0; +} + static int diff_opt_color_words(const struct option *opt, const char *arg, int unset) { @@ -5339,6 +5360,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "color-words", options, N_(""), N_("equivalent to --word-diff=color --word-diff-regex="), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_color_words), + OPT_CALLBACK_F(0, "color-moved", options, N_(""), + N_("move lines of code are colored differently"), + PARSE_OPT_OPTARG, diff_opt_color_moved), OPT_GROUP(N_("Diff other options")), OPT_CALLBACK_F(0, "relative", options, N_(""), @@ -5422,19 +5446,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* flags options */ - if (!strcmp(arg, "--color-moved")) { - if (diff_color_moved_default) - options->color_moved = diff_color_moved_default; - if (options->color_moved == COLOR_MOVED_NO) - options->color_moved = COLOR_MOVED_DEFAULT; - } else if (!strcmp(arg, "--no-color-moved")) - options->color_moved = COLOR_MOVED_NO; - else if (skip_prefix(arg, "--color-moved=", &arg)) { - int cm = parse_color_moved(arg); - if (cm < 0) - return error("bad --color-moved argument: %s", arg); - options->color_moved = cm; - } else if (skip_prefix(arg, "--color-moved-ws=", &arg)) { + if (skip_prefix(arg, "--color-moved-ws=", &arg)) { unsigned cm = parse_color_moved_ws(arg); if (cm & COLOR_MOVED_WS_ERROR) return -1; From patchwork Sun Mar 24 08:20:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CBBA71669 for ; Sun, 24 Mar 2019 08:22:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB85A29829 for ; Sun, 24 Mar 2019 08:22:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B005029830; Sun, 24 Mar 2019 08:22:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5884829829 for ; Sun, 24 Mar 2019 08:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728601AbfCXIWg (ORCPT ); Sun, 24 Mar 2019 04:22:36 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34539 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbfCXIWg (ORCPT ); Sun, 24 Mar 2019 04:22:36 -0400 Received: by mail-pf1-f196.google.com with SMTP id b3so2921199pfd.1 for ; Sun, 24 Mar 2019 01:22:35 -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=PCGsr2ZQ6uQ8MBfgTTePhHiE9iA2BhAP7Fwp0I89j2g=; b=lSfBL96BeMXM6kaSJH1HdbrCQY3oH88eVJ6gEfjH+tpdgwCQLaSoUO0qw/yDSiUB+t 9PVIS7uMTjuEwM2GuxJ27EQyyWrlYG75NTxPwtceAYwnYeAXVuB3eXsFemWrI3RbL/yw AB4AQffIJTRLv0qlcGb0ahfvJnrCU0NiLtviHknpv4IP8ZNVSAKGVdyRCcfCYQCVmLhU VZ6c1CCWshvMQrKmpR0E72tKN5036SV/Gry88h4Jzet1fGd9FDkj32Y44a9CbriD8i58 TnJiANsx7KhF4DyY2vr75hkjmSscyNT5MSCL8EYCMAo0cbtbdHjTdJjsATAiPHTlPUzs e1tw== 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=PCGsr2ZQ6uQ8MBfgTTePhHiE9iA2BhAP7Fwp0I89j2g=; b=rZDGFF3L/S5HzTL1jq3LUuG/zX6aAHeG+orvgyKC0qy9LeAJ/BU+rEFnAk8vHtau8G kw9bvWLedNRNfA03hpOxL1RLPt3ebL2PjoctjdqfW/clq1RPoWwmVtY6zxJJNrq65bVx vnqce94ebk3ApzpYUsPxppxPCPynv7NVWL5UmugUdP3ybLoIh0l6gA4juozyp634eRvq OnHl6+dVCr0QpVaHcaAdxtvsD9HzgGpQoN6tA7fWYcAivyfLFGjJbucwDSpRkAnnAHfN gt9Kcg04YmWOgjLiaVqQ15xA0dgmdKFZ0XGx9MorxSOnPM34u6KI/cuKTUiD0FH4Gju0 lQsw== X-Gm-Message-State: APjAAAUH2ccVevRGDsjwaiZLugEEK63xtsIeJ+c8vS+sC0wJURPCu5XC elzrc2EK0c+Sz2JKLfk4sS0zMYCI X-Google-Smtp-Source: APXvYqwa4je8xwnxTZuQEdCIg0kqBt8eLJDLbm9mq8K2FGhU1Or5Tg/BWUGFZDttZoYvMSFSUSSQ5g== X-Received: by 2002:a65:628f:: with SMTP id f15mr17802327pgv.410.1553415755543; Sun, 24 Mar 2019 01:22:35 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id l7sm41068169pfj.162.2019.03.24.01.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:34 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:30 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 16/20] diff-parseopt: convert --color-moved-ws Date: Sun, 24 Mar 2019 15:20:10 +0700 Message-Id: <20190324082014.2041-17-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/diff.c b/diff.c index de6c09e95a..1a24bbfb69 100644 --- a/diff.c +++ b/diff.c @@ -4862,6 +4862,20 @@ static int diff_opt_color_moved(const struct option *opt, return 0; } +static int diff_opt_color_moved_ws(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + unsigned cm; + + BUG_ON_OPT_NEG(unset); + cm = parse_color_moved_ws(arg); + if (cm & COLOR_MOVED_WS_ERROR) + return error(_("invalid mode '%s' in --color-moved-ws"), arg); + options->color_moved_ws_handling = cm; + return 0; +} + static int diff_opt_color_words(const struct option *opt, const char *arg, int unset) { @@ -5363,6 +5377,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "color-moved", options, N_(""), N_("move lines of code are colored differently"), PARSE_OPT_OPTARG, diff_opt_color_moved), + OPT_CALLBACK_F(0, "color-moved-ws", options, N_(""), + N_("how white spaces are ignored in --color-moved"), + PARSE_OPT_NONEG, diff_opt_color_moved_ws), OPT_GROUP(N_("Diff other options")), OPT_CALLBACK_F(0, "relative", options, N_(""), @@ -5430,8 +5447,6 @@ static void prep_parse_options(struct diff_options *options) int diff_opt_parse(struct diff_options *options, const char **av, int ac, const char *prefix) { - const char *arg = av[0]; - if (!prefix) prefix = ""; @@ -5442,21 +5457,7 @@ int diff_opt_parse(struct diff_options *options, PARSE_OPT_ONE_SHOT | PARSE_OPT_STOP_AT_NON_OPTION); - if (ac) - return ac; - - /* flags options */ - if (skip_prefix(arg, "--color-moved-ws=", &arg)) { - unsigned cm = parse_color_moved_ws(arg); - if (cm & COLOR_MOVED_WS_ERROR) - return -1; - options->color_moved_ws_handling = cm; - } - - /* misc options */ - else - return 0; - return 1; + return ac; } int parse_rename_score(const char **cp_p) From patchwork Sun Mar 24 08:20:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 97B32922 for ; Sun, 24 Mar 2019 08:22:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8789C29829 for ; Sun, 24 Mar 2019 08:22:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7988729830; Sun, 24 Mar 2019 08:22:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237BB29829 for ; Sun, 24 Mar 2019 08:22:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728603AbfCXIWl (ORCPT ); Sun, 24 Mar 2019 04:22:41 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39337 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbfCXIWl (ORCPT ); Sun, 24 Mar 2019 04:22:41 -0400 Received: by mail-pg1-f195.google.com with SMTP id k3so647407pga.6 for ; Sun, 24 Mar 2019 01:22:40 -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=wb8g3tH7tNB9j1cMay16kwDkp7KosDSsLF9ejJK+bo0=; b=KpKzyY5pdEhOxoesiCkyVp6GxXkkk0pyBwNA8PCcspHxIlsSQ/Ts9SEcnbZa7PSVnr dXZk9zwfoWVVBk5OVybK8MSRV+UFuh212hVqvdtBJ+EyKXM0KTH1hGqBBlITqIzkNg6V 6LDSyONccNniSZvY294vRxxJmXl/nrECnB07neGsyjWS6E6a62foWcSRyEbDEa/ux2t8 i/BWhM+yXf44T/EYLjnGN8PrNs/J4BlkbZuB3cH3+rZFH9Wm5GtgzWlvSrsdZyjsoq4L xzMaYOrvRTUc0981iPlSSAMDEAwOsI1i9HYLOizTVot69myZ3B6hhB0A7IkGnObuQahd bcMA== 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=wb8g3tH7tNB9j1cMay16kwDkp7KosDSsLF9ejJK+bo0=; b=q9EMNOxauxzwYljfgYGy+nzaBZXtlEi31HrfNv/C/QKNotVJKPfNKgYRQLlLcgybwm SQUVhZkNvI1BL/mhBUCd/qPBEpuDjlXpYyS7xrO4sAthhRdx8NgqYs8s8CEvHq9qgxah TQ0XlGCffaZF3Kt1mCpWdVKHZ4qxD3iOQchjog02c5d54f49QfLX12RP5qc/Wh8r9r9Q NBRJboiC+jn742EtRVMqIJo4UG+ND6WHKw8RomFbczUzAtN5ynVD+8/dX5IoEckcQd14 yfCpm9VniIiis5jb8FDmCUtYiWtOjr4atu9rQ5r7AZo9aggRc0a4+SPrVusu54wy5on1 DClw== X-Gm-Message-State: APjAAAVzGYWcKw5R35DcFXlwNCj8RQ5GHT4X9c6zsziOXpO5BXPSTSXh JWQA3uBZ6P+VRKFbovu+h1M= X-Google-Smtp-Source: APXvYqzfh6/M+quCppm4XYeNCO1xiEwQNNmbgx8NLi2hVNXZNty0f/1HH+DhYYQO+R8IzljQrElk4Q== X-Received: by 2002:a63:ff5a:: with SMTP id s26mr16357522pgk.96.1553415760436; Sun, 24 Mar 2019 01:22:40 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id t64sm9137824pfa.86.2019.03.24.01.22.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:39 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:35 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 17/20] diff.c: allow --no-color-moved-ws Date: Sun, 24 Mar 2019 15:20:11 +0700 Message-Id: <20190324082014.2041-18-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This option is added in commit b73bcbac4a (diff: allow --no-color-moved-ws - 2018-11-23) in pw/diff-color-moved-ws-fix. To ease merge conflict resolution, re-implement the option handling here so that the conflict could be resolved by taking this side of change. Signed-off-by: Nguyễn Thái Ngọc Duy --- diff.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index 1a24bbfb69..8b770cd396 100644 --- a/diff.c +++ b/diff.c @@ -4868,7 +4868,11 @@ static int diff_opt_color_moved_ws(const struct option *opt, struct diff_options *options = opt->value; unsigned cm; - BUG_ON_OPT_NEG(unset); + if (unset) { + options->color_moved_ws_handling = 0; + return 0; + } + cm = parse_color_moved_ws(arg); if (cm & COLOR_MOVED_WS_ERROR) return error(_("invalid mode '%s' in --color-moved-ws"), arg); @@ -5379,7 +5383,7 @@ static void prep_parse_options(struct diff_options *options) PARSE_OPT_OPTARG, diff_opt_color_moved), OPT_CALLBACK_F(0, "color-moved-ws", options, N_(""), N_("how white spaces are ignored in --color-moved"), - PARSE_OPT_NONEG, diff_opt_color_moved_ws), + 0, diff_opt_color_moved_ws), OPT_GROUP(N_("Diff other options")), OPT_CALLBACK_F(0, "relative", options, N_(""), From patchwork Sun Mar 24 08:20:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB9771669 for ; Sun, 24 Mar 2019 08:22:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA3DC29829 for ; Sun, 24 Mar 2019 08:22:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEC5529830; Sun, 24 Mar 2019 08:22:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6399229829 for ; Sun, 24 Mar 2019 08:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728331AbfCXIWq (ORCPT ); Sun, 24 Mar 2019 04:22:46 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40395 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728029AbfCXIWq (ORCPT ); Sun, 24 Mar 2019 04:22:46 -0400 Received: by mail-pf1-f195.google.com with SMTP id c207so4295788pfc.7 for ; Sun, 24 Mar 2019 01:22:45 -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=TBATZcC9BN4zxj/mXAHdQlMKZmVPFPE1YF5xpIyEjjw=; b=ir3pvhQNU4wUeuRVTbLiJwZlFCtj3L/cBO1GLJiR6tHkYouHImd+7tzDtjyXYwz07E EBpQJor0UqcDoiwN5DU9oSG6U9GB0xPr7ixUI+Fsu/qVd9KK+0n7w56bWvX87zY5jhev ZN8AT9+RjyTzRlhRQfHfzPPvIJdSlF2Y9zHBV15MIlfoWy5mOpfPptr32bZuGD2rNilw +DVYcltQWLpX26mI+3eqjThm3WJrZt4rF4ixttTbBJS6KHvtwmdxT0iOEbV7lGBP6eWa gYjeE9Ubc2DjIKQXkBcyIOjymOa4zuLkf+TD+G/nAZBVg5nnonFVSaAf4RcbbNXo74Cc Xe9g== 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=TBATZcC9BN4zxj/mXAHdQlMKZmVPFPE1YF5xpIyEjjw=; b=Oi/zpCd2VsjNE1VSZ+LymWTNGNj5hbxpXVBXm3n9TDZoJW5mKs9tCa2PfV+QsRJj2p 02OyaiTeocXWs4FKg77faH3AEPxvVLvvVGCzqg8WsY0vclWnjeqZNb95is7O88427fsM VUcGhwJ3bmUq4vMkSBzhgXKnChgEojX9M1tZ1iMBcPm3+XfdR4LNaTlO99MD6Fi4aJeE mKTZOp3bLSBHI4Je4z7XXCOrKy0KIxS/KUMtb0/2DnNyPNgKP4XjGPMEX0WXbxIWxuuc l2FMBkG8wbBQzvk+ChXqLeH2uw7X6iFQzwgthhKtE/73mjUpdyxnmPnMzYc9MqZfzsuH jiaQ== X-Gm-Message-State: APjAAAWUhFyv5GlM523X1Qy8cnuVQ5tF1RplUHU5oTl2qfLvQ6agT+yt 1HNEUlf0LV+p7NjJ4UXSJ+WsEPxU X-Google-Smtp-Source: APXvYqxvUFqvHrqSjHIA27gR3rbDaCDktiqGeNq6a02CCAG8Sqe0YHUNE9xIVo8AEe9BICJ5BRYfEQ== X-Received: by 2002:a63:2aca:: with SMTP id q193mr17633783pgq.269.1553415765425; Sun, 24 Mar 2019 01:22:45 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id f65sm19264182pff.21.2019.03.24.01.22.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:44 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:40 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 18/20] range-diff: use parse_options() instead of diff_opt_parse() Date: Sun, 24 Mar 2019 15:20:12 +0700 Message-Id: <20190324082014.2041-19-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Diff's internal option parsing is now done with 'struct option', which makes it possible to combine all diff options to range-diff and parse everything all at once. Parsing code becomes simpler, and we get a looong 'git range-diff -h' Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/range-diff.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/builtin/range-diff.c b/builtin/range-diff.c index f01a0be851..784bd19321 100644 --- a/builtin/range-diff.c +++ b/builtin/range-diff.c @@ -16,42 +16,27 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix) int creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT; struct diff_options diffopt = { NULL }; int simple_color = -1; - struct option options[] = { + struct option range_diff_options[] = { OPT_INTEGER(0, "creation-factor", &creation_factor, N_("Percentage by which creation is weighted")), OPT_BOOL(0, "no-dual-color", &simple_color, N_("use simple diff colors")), OPT_END() }; - int i, j, res = 0; + struct option *options; + int res = 0; struct strbuf range1 = STRBUF_INIT, range2 = STRBUF_INIT; git_config(git_diff_ui_config, NULL); repo_diff_setup(the_repository, &diffopt); + options = parse_options_concat(range_diff_options, diffopt.parseopts); argc = parse_options(argc, argv, NULL, options, - builtin_range_diff_usage, PARSE_OPT_KEEP_UNKNOWN | - PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0); - - for (i = j = 1; i < argc && strcmp("--", argv[i]); ) { - int c = diff_opt_parse(&diffopt, argv + i, argc - i, prefix); + builtin_range_diff_usage, 0); - if (!c) - argv[j++] = argv[i++]; - else - i += c; - } - while (i < argc) - argv[j++] = argv[i++]; - argc = j; diff_setup_done(&diffopt); - /* Make sure that there are no unparsed options */ - argc = parse_options(argc, argv, NULL, - options + ARRAY_SIZE(options) - 1, /* OPT_END */ - builtin_range_diff_usage, 0); - /* force color when --dual-color was used */ if (!simple_color) diffopt.use_color = 1; @@ -90,6 +75,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix) error(_("need two commit ranges")); usage_with_options(builtin_range_diff_usage, options); } + FREE_AND_NULL(options); res = show_range_diff(range1.buf, range2.buf, creation_factor, simple_color < 1, &diffopt); From patchwork Sun Mar 24 08:20:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03B181669 for ; Sun, 24 Mar 2019 08:22:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E37EE29829 for ; Sun, 24 Mar 2019 08:22:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D762529830; Sun, 24 Mar 2019 08:22:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55EBE2982E for ; Sun, 24 Mar 2019 08:22:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728346AbfCXIWv (ORCPT ); Sun, 24 Mar 2019 04:22:51 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37343 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbfCXIWv (ORCPT ); Sun, 24 Mar 2019 04:22:51 -0400 Received: by mail-pf1-f196.google.com with SMTP id 8so4298566pfr.4 for ; Sun, 24 Mar 2019 01:22:50 -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=vsSDRcoBc73cq8zBNzh03Mr5G+WB2dtVwogFKvxBObw=; b=MTgbCX1rR64DFhyRUbbsbuWBcAEuy9OyyFrlj5clSXvo3Rccmqz6s63TObWlyo02f4 YpWLRgycS7+9XSgvdf+F5V2ozCvvBSpRKd+xz0ZQJfy2l7y7QwAol8aK0mNZhnpVKl5c LoQlXo9WH+P7h2I+81Ea0cUsCYCgFeuvllHQkoMr+jPk8wAhv19owRZoC+KBynO1HJd/ QqdqgjnEl4lzf6YOgEhooU/TfVwfTQJb0p6NwGBEDE4+dvQR7nG57FyRwsM1+djJ+QjT DKcSa/rS/XoMqlemLv6zNJsbmRO6ro14LFgn3cdkzIJRiL/L6vON4BmoAXP/sxR6prJD UZZA== 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=vsSDRcoBc73cq8zBNzh03Mr5G+WB2dtVwogFKvxBObw=; b=klk6HzY6sQQujdaBoXVKiCT6RmwcgjGuayy1OBRyBtX3k/yhJnrBHMf11YSyIQeCEe oUUWQx1jIpG5XtHhfWxH5INrDl3gFKIE/ljomWRD6R/xJYKFkQlLgefK8OjR6WHDFGpJ pKMILb973b58ihewzmujkNgNwM3xznVHCPaBJck9yhzEuZpFU1HI2jOptroMWQmtl4r+ WBkpx21eLwHQwg5JrhG0txXraIvbPeZr8Hx/7WN3gbjyzbFgyQlX83vAI3Bc6ffR61Lr N+ahpEbsj4Xfvb6xSYI2Y30ZzGIj3/fXirmkwxRAbrwxRJgJDzj9Lg4arJdaAjaliFyN F81Q== X-Gm-Message-State: APjAAAVMJjbP4gKA5pA+nkPLOTZFD3+tVTABnMVLbdcZxulQ6uMJjPJD 0tAh6jyqo4G60u6MeYrUlIBJbbuc X-Google-Smtp-Source: APXvYqxtwTMDX52PaRMOPdmKHrIwNYcuicawUMDCVdkMJgtEDfYUpbdO2+ySL5vLkvtyaWIalpy6pQ== X-Received: by 2002:a63:450f:: with SMTP id s15mr17169528pga.157.1553415770506; Sun, 24 Mar 2019 01:22:50 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id m79sm26723595pfi.60.2019.03.24.01.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:49 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:45 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 19/20] diff --no-index: use parse_options() instead of diff_opt_parse() Date: Sun, 24 Mar 2019 15:20:13 +0700 Message-Id: <20190324082014.2041-20-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While at there, move exit() back to the caller. It's easier to see the flow that way than burying it in diff-no-index.c Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/diff.c | 21 +++-------------- diff-no-index.c | 49 ++++++++++++++++++++++++---------------- diff.h | 3 ++- t/t4053-diff-no-index.sh | 3 +-- 4 files changed, 35 insertions(+), 41 deletions(-) diff --git a/builtin/diff.c b/builtin/diff.c index f0393bba23..52dc3e136f 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -320,26 +320,11 @@ int cmd_diff(int argc, const char **argv, const char *prefix) repo_init_revisions(the_repository, &rev, prefix); - if (no_index && argc != i + 2) { - if (no_index == DIFF_NO_INDEX_IMPLICIT) { - /* - * There was no --no-index and there were not two - * paths. It is possible that the user intended - * to do an inside-repository operation. - */ - fprintf(stderr, "Not a git repository\n"); - fprintf(stderr, - "To compare two paths outside a working tree:\n"); - } - /* Give the usage message for non-repository usage and exit. */ - usagef("git diff %s ", - no_index == DIFF_NO_INDEX_EXPLICIT ? - "--no-index" : "[--no-index]"); - - } if (no_index) /* If this is a no-index diff, just run it and exit there. */ - diff_no_index(the_repository, &rev, argc, argv); + exit(diff_no_index(the_repository, &rev, + no_index == DIFF_NO_INDEX_IMPLICIT, + argc, argv)); /* Otherwise, we are doing the usual "git" diff */ rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index; diff --git a/diff-no-index.c b/diff-no-index.c index 9414e922d1..a879f45862 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -14,6 +14,7 @@ #include "revision.h" #include "log-tree.h" #include "builtin.h" +#include "parse-options.h" #include "string-list.h" #include "dir.h" @@ -233,35 +234,43 @@ static void fixup_paths(const char **path, struct strbuf *replacement) } } -void diff_no_index(struct repository *r, - struct rev_info *revs, - int argc, const char **argv) +static const char * const diff_no_index_usage[] = { + N_("git diff --no-index [] "), + NULL +}; + +int diff_no_index(struct repository *r, + struct rev_info *revs, + int implicit_no_index, + int argc, const char **argv) { - int i; + int i, no_index; const char *paths[2]; struct strbuf replacement = STRBUF_INIT; const char *prefix = revs->prefix; + struct option no_index_options[] = { + OPT_BOOL_F(0, "no-index", &no_index, "", + PARSE_OPT_NONEG | PARSE_OPT_HIDDEN), + OPT_END(), + }; + struct option *options; /* * FIXME: --no-index should not look at index and we should be * able to pass NULL repo. Maybe later. */ repo_diff_setup(r, &revs->diffopt); - for (i = 1; i < argc - 2; ) { - int j; - if (!strcmp(argv[i], "--no-index")) - i++; - else if (!strcmp(argv[i], "--")) - i++; - else { - j = diff_opt_parse(&revs->diffopt, argv + i, argc - i, - revs->prefix); - if (j <= 0) - die("invalid diff option/value: %s", argv[i]); - i += j; - } + options = parse_options_concat(no_index_options, + revs->diffopt.parseopts); + argc = parse_options(argc, argv, revs->prefix, options, + diff_no_index_usage, 0); + if (argc != 2) { + if (implicit_no_index) + warning(_("Not a git repository. Use --no-index to " + "compare two paths outside a working tree")); + usage_with_options(diff_no_index_usage, options); } - + FREE_AND_NULL(options); for (i = 0; i < 2; i++) { const char *p = argv[argc - 2 + i]; if (!strcmp(p, "-")) @@ -293,7 +302,7 @@ void diff_no_index(struct repository *r, revs->diffopt.flags.exit_with_status = 1; if (queue_diff(&revs->diffopt, paths[0], paths[1])) - exit(1); + return 1; diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/"); diffcore_std(&revs->diffopt); diff_flush(&revs->diffopt); @@ -304,5 +313,5 @@ void diff_no_index(struct repository *r, * The return code for --no-index imitates diff(1): * 0 = no changes, 1 = changes, else error */ - exit(diff_result_code(&revs->diffopt, 0)); + return diff_result_code(&revs->diffopt, 0); } diff --git a/diff.h b/diff.h index d9ad73f0e1..03c6afda22 100644 --- a/diff.h +++ b/diff.h @@ -437,7 +437,8 @@ int diff_flush_patch_id(struct diff_options *, struct object_id *, int); int diff_result_code(struct diff_options *, int); -void diff_no_index(struct repository *, struct rev_info *, int, const char **); +int diff_no_index(struct repository *, struct rev_info *, + int implicit_no_index, int, const char **); int index_differs_from(struct repository *r, const char *def, const struct diff_flags *flags, diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh index 6e0dd6f9e5..fb25cdb789 100755 --- a/t/t4053-diff-no-index.sh +++ b/t/t4053-diff-no-index.sh @@ -50,8 +50,7 @@ test_expect_success 'git diff --no-index executed outside repo gives correct err export GIT_CEILING_DIRECTORIES && cd non/git && test_must_fail git diff --no-index a 2>actual.err && - echo "usage: git diff --no-index " >expect.err && - test_cmp expect.err actual.err + test_i18ngrep "usage: git diff --no-index" actual.err ) ' From patchwork Sun Mar 24 08:20:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10867397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BF52922 for ; Sun, 24 Mar 2019 08:22:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08F0429829 for ; Sun, 24 Mar 2019 08:22:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F19C829830; Sun, 24 Mar 2019 08:22:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9562829829 for ; Sun, 24 Mar 2019 08:22:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728604AbfCXIW4 (ORCPT ); Sun, 24 Mar 2019 04:22:56 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42144 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728372AbfCXIW4 (ORCPT ); Sun, 24 Mar 2019 04:22:56 -0400 Received: by mail-pg1-f196.google.com with SMTP id p6so4344204pgh.9 for ; Sun, 24 Mar 2019 01:22:55 -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=aiSmXcPWwuUlZwOaeK3ivjrxGNj+j1bDAtipP1bbsHM=; b=MMjAKCohFdfn5xZhz3Rjy5G+SQ3Ij0ejCPFN3o1T6XWk3ftL4vHCU0p1Ar2JptbCVh ec77quzqwMgpUS1JJr2OzN0eKszfzasNPDejWtmnYaE9y31qjnqochFNQgkxzuK6ykZT 6rbaycUbNiD98FhkI4HFte1NwEgQms2N514E9RSr1bEauvyHS89uJ6PWg/ieF/BD8eHT /sIBlL2weMTfpLVmyq01nQ0nR+waRQ83i2/0jlmsqv3qcs539si5Ui1Xh2UAuU+l5QJj JrORx4JSI5cnNAu6wOgBigLkWVUo6+9a6Bwohv5Vz1Qg1Tw4dzZ0kxWjwazpmFUE09hl ho5A== 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=aiSmXcPWwuUlZwOaeK3ivjrxGNj+j1bDAtipP1bbsHM=; b=itqX0cwxy9tPUMigg4ANbpvXXT+0wcAHSHL/M6jp3K+vKY1x5vai9RzdhROlRT73ko kqNqPTt/aF3UhLhQlhEjzvUyUveJ8KqJ9AnGqRAfakPzj9A9JSmIOrOoEi/XJ0GqM0un zNzavHTKOYysDSIKbqH+R/aGHVWNDKZt+5jUgXVjmcGvOtu/1eKY/NxLxELsolPO5rUB XiuXu9gQqARIGorKzKTjNj9RYNALULJxepb6cPV/iqkMwoka+Av3T3uB3peqMnFXBTUb bSr96pr0UrGLKJZ0BjZeoHQRA3vEgR5+mRU2GxhhR1nX/uW9WwzP/9XcpCVGA+usZsTM kNUA== X-Gm-Message-State: APjAAAU6SO8oeKhthYj3Kzwpmfy8D9jnZoys8Tt0hjECRkdcNDsu2XU9 Ox93tDt3DBi+NfR+hESsAz0= X-Google-Smtp-Source: APXvYqwxOFqu6FUVxXqqy0qD3DiZsiuKSxA/Gx4i4T+pl8ILMrZHUvvUOV6cbe1kAILL1sJXKvOs/A== X-Received: by 2002:a17:902:6b48:: with SMTP id g8mr18701431plt.21.1553415775574; Sun, 24 Mar 2019 01:22:55 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id s79sm25236562pfa.61.2019.03.24.01.22.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 01:22:54 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Sun, 24 Mar 2019 15:22:50 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, Junio C Hamano , =?utf-8?q?Marti?= =?utf-8?q?n_=C3=85gren?= Subject: [PATCH v2 20/20] am: avoid diff_opt_parse() Date: Sun, 24 Mar 2019 15:20:14 +0700 Message-Id: <20190324082014.2041-21-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190324082014.2041-1-pclouds@gmail.com> References: <20190320114703.18659-1-pclouds@gmail.com> <20190324082014.2041-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP diff_opt_parse() is a heavy hammer to just set diff filter. But it's the only way because of the diff_status_letters[] mapping. Add a new API to set diff filter and use it in git-am. diff_opt_parse()'s only remaining call site in revision.c will be gone soon and having it here just because of git-am does not make sense. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/am.c | 4 ++-- diff.c | 6 ++++++ diff.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/builtin/am.c b/builtin/am.c index 95370313b6..0cbf285459 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1515,11 +1515,11 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa * review them with extra care to spot mismerges. */ struct rev_info rev_info; - const char *diff_filter_str = "--diff-filter=AM"; repo_init_revisions(the_repository, &rev_info, NULL); rev_info.diffopt.output_format = DIFF_FORMAT_NAME_STATUS; - diff_opt_parse(&rev_info.diffopt, &diff_filter_str, 1, rev_info.prefix); + rev_info.diffopt.filter |= diff_filter_bit('A'); + rev_info.diffopt.filter |= diff_filter_bit('M'); add_pending_oid(&rev_info, "HEAD", &our_tree, 0); diff_setup_done(&rev_info.diffopt); run_diff_index(&rev_info, 1); diff --git a/diff.c b/diff.c index 8b770cd396..11f26285c3 100644 --- a/diff.c +++ b/diff.c @@ -4692,6 +4692,12 @@ static unsigned filter_bit_tst(char status, const struct diff_options *opt) return opt->filter & filter_bit[(int) status]; } +unsigned diff_filter_bit(char status) +{ + prepare_filter_bits(); + return filter_bit[(int) status]; +} + static int diff_opt_diff_filter(const struct option *option, const char *optarg, int unset) { diff --git a/diff.h b/diff.h index 03c6afda22..f88482705c 100644 --- a/diff.h +++ b/diff.h @@ -233,6 +233,8 @@ struct diff_options { struct option *parseopts; }; +unsigned diff_filter_bit(char status); + void diff_emit_submodule_del(struct diff_options *o, const char *line); void diff_emit_submodule_add(struct diff_options *o, const char *line); void diff_emit_submodule_untracked(struct diff_options *o, const char *path);