From patchwork Wed Mar 20 11:46:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861449 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 78C4C1390 for ; Wed, 20 Mar 2019 11:47:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D85B29ABB for ; Wed, 20 Mar 2019 11:47:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51BC229B62; Wed, 20 Mar 2019 11:47:21 +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 F126729ABB for ; Wed, 20 Mar 2019 11:47:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728018AbfCTLrT (ORCPT ); Wed, 20 Mar 2019 07:47:19 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46766 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLrT (ORCPT ); Wed, 20 Mar 2019 07:47:19 -0400 Received: by mail-pf1-f194.google.com with SMTP id 9so1511194pfj.13 for ; Wed, 20 Mar 2019 04:47:19 -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=LiJB+dZjjt2X8+jJDU+zTil0o4YfrW7krPl0Sorxmas=; b=JjQcFkSlrNMq/TnjPn6kwV4UuCxAuM1Hb2X/TJDVZm7+OJCOD+aLU5WlvPQUpU0EN6 Wce6wY7TpGtfMp+MnMt0pB06QQpi7VCpBTjkoSCbstHxVJaMcq2smEVPxobSoaUlgQbG VjwEL7+33SL5sMBlrKF9tsMibqSe3TkqMuxV6UWa0+aMJQBFL+9GMYYahFwVw+Rqn+it sgTAlWoNSiEW/WrB/uoWAAoRN4IpWYeBlUENjbFrjcF1tBBCku9ubSDXwWuSp+I96wJn PQSb5MDDI/DMRnICiW5DNay8MN62mDMtb5SFBdr5QdW+DfSrDbY924qTbALwEjVF/1K0 JgWQ== 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=LiJB+dZjjt2X8+jJDU+zTil0o4YfrW7krPl0Sorxmas=; b=KSbR1TmZXiFP7QKJxmEeVg+Y5FXYxPCzx3z+sX8D0zxtFDYoKswjN33i1Kz4fpIIZF JXACMpUJgyVYxmICa47hk1NjVK7FzNMMx7hcmqcpdz9Q//qxPQRs1H0QOroEPL06dXJu mBuZ9doahnPM9AdduTMKmFrEE/Zybk2C/HzK4ToIZ3y2tsFV1aLU7bjroHOyR9tn9kIt 82WCUGf+QpmLoGEQRAMYXeAY5QtQvF4L8lBk+uAbIzqitTbEsx8jgjF2LLtyQSfL2N17 +nyNb2wbnmZFSNWvK9ghk0ukEb4en1RjJSDYbsCuQlhzm/tVkTIk3ppxIu/rl/qa0uQK JgEg== X-Gm-Message-State: APjAAAWk6DE8k0SjGwOuX5cwj01QtQwG137a4TBpkKcRiq+d43FVwkHM oDHf44ehEqhzIA8TZkV+vu93cJtC X-Google-Smtp-Source: APXvYqwQqUHNnS8eimuPJW02JZP0ZzaaVTXgM/I4466f8RBdROO8tEwTUaAOUnNr/hnRZFyD6HWigg== X-Received: by 2002:a62:f94b:: with SMTP id g11mr7231017pfm.199.1553082438711; Wed, 20 Mar 2019 04:47:18 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id t8sm2088516pgp.5.2019.03.20.04.47.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:18 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:13 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 01/20] diff-parseopt: convert --ws-error-highlight Date: Wed, 20 Mar 2019 18:46:44 +0700 Message-Id: <20190320114703.18659-2-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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..8fdcdcc8ff 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 whitespaces 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 Wed Mar 20 11:46:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861451 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 CBEAC15AC for ; Wed, 20 Mar 2019 11:47:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE8CA296DB for ; Wed, 20 Mar 2019 11:47:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A357E29B5F; Wed, 20 Mar 2019 11:47:25 +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 4F54D296DB for ; Wed, 20 Mar 2019 11:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728025AbfCTLrY (ORCPT ); Wed, 20 Mar 2019 07:47:24 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34402 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLrX (ORCPT ); Wed, 20 Mar 2019 07:47:23 -0400 Received: by mail-pg1-f193.google.com with SMTP id v12so1644798pgq.1 for ; Wed, 20 Mar 2019 04:47:23 -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=Sh6kI7svlAYMZ/6jUd3R1fDDCJIXeZ0ov/IzRrpHk6U=; b=MXyu65FZcdDxxGxnsuQZINvp68GHXJAVqXegbU2lwMrK3A7o/QqejQBQA+gxn12T2v DpXvgE2H9tokryHYEf79wE1BdmMa/VL4ZkrYPgRUDBmmDBH7SCjbb7RvXw++xO6YlaJD 1jb7T2yAXCSIQeTMdAod4o5vyhJpxk0T31REnZZI80tRna+5z5V8fpqvNDLVTsJjZ1DC B6GBcjAnikaU9+wktlBTyCn8Yx671X71KQzzPgDJwATpE3FHArfv0iB6/qqd+k7bqnsP RAALoo+OEZPvGQnsLkc0jbIRuhBu0r7ktqKLoeT8Dmf8OqRhvu5p09ORYTw9PhbdDMV6 c3vg== 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=Sh6kI7svlAYMZ/6jUd3R1fDDCJIXeZ0ov/IzRrpHk6U=; b=sKpeknR3TJkA8W4I/O5Tl4qdIGiGP18W8hFqsUU7gB+akMrlsB8EO3dT9W33jPLHDV qQ3dti38kyjwl1O7Rn6PTrIdC9W3v6Uyx2AhcDq+UIcR4DdvxsROPZDvUyeWkxBhqLEL 7gzmrVbLHjyD9S3b2ZdvIFN1OmFdvpLgGwI0UKusIYHrmkH4EgkkWZlbVVrpJE3Lf1yR kDPaI1UWlja+9BrtiI/QhI3GsOwNlKTIEH/ajEoabKtnwT8XC7iTruDXvtKTfA5wuXKq t8CzuSQbgXf40p0DgJFDM0tfw1zItIZR/yONhA1ex3PJd5TPISL+Rdp8oeJglbBclbML EShQ== X-Gm-Message-State: APjAAAVeOQjHpJ45NEqj3MUG20mCSoOuajc6zHXXRJ2pIO/o1Zyehe2j E+9qBkqMJWVcf8WN7XoebQQxn4cd X-Google-Smtp-Source: APXvYqwQD2+rbBUezJpp8J3Na2XpYcgWN1GB6rGHF92aSBHIODBfQ8GCUZ1X94vnHBaxwO1Cq8fGVQ== X-Received: by 2002:a17:902:442:: with SMTP id 60mr23947002ple.107.1553082443211; Wed, 20 Mar 2019 04:47:23 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id p86sm3636227pfa.104.2019.03.20.04.47.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:22 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:19 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 02/20] diff-parseopt: convert --ita-[in]visible-in-index Date: Wed, 20 Mar 2019 18:46:45 +0700 Message-Id: <20190320114703.18659-3-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 8fdcdcc8ff..3eace63172 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 Wed Mar 20 11:46:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861453 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 1591115AC for ; Wed, 20 Mar 2019 11:47:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F07CA29A14 for ; Wed, 20 Mar 2019 11:47:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E497A29B55; Wed, 20 Mar 2019 11:47:29 +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 97FFA29A14 for ; Wed, 20 Mar 2019 11:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728029AbfCTLr2 (ORCPT ); Wed, 20 Mar 2019 07:47:28 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44494 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLr2 (ORCPT ); Wed, 20 Mar 2019 07:47:28 -0400 Received: by mail-pg1-f195.google.com with SMTP id i2so1611224pgj.11 for ; Wed, 20 Mar 2019 04:47:28 -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=eyeB0ppx8aJQ1JlABpv9PqME2hGRTV5LppLxCax4nFI=; b=bwx/5Ov5sCEf+lOZdi1k7+c54GctwcSGhhKtjnaTGCdbWjFzwcBPOp6VaBcFSf9XsY INrSmX5/losTjBXpIrPiJ1aZqodf2SmSOWceUrukxUhUc749FblscB6hIwHEgatZLh5I q5GyfBEudx+n7wbR57auFeVMdf7osSJp9Mz+c4gVBz4dLq02Rvy5JeFWeFHFZPfITMQf SdpzDpwp4OgSgrBEts1HUG4cbDL8YKOuuSm6x4+FmjB8aub66rKqlUNugNO3154wvCLN OXwTFK5+GGtJcUFQ9rIYYtDiX4sjvWPzGSns69ngb41Eh57TNcO8xYPorX/cgulS0HNN +ovg== 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=eyeB0ppx8aJQ1JlABpv9PqME2hGRTV5LppLxCax4nFI=; b=YZW0Ica9Pj4EjN7d4Y9LitHWWvbXi+DdziIkc+2M6yzNEaySJ5mEEafn8Koj2OlikK fbRQHNT6B6auqnFVCdENXsLyCVqmCFuOZT8d1lU+EPQSCXqfuEa5j5BnjdrGO9SfHvKV swhuqecLiEtDsJYkR8CXx5YgH2SnBCdc+80j1QF8DcSF49SWRDs7NdB69vQ59p9SP2IZ DS7nY+cgcinYMzgQCLLIG/iUWyIH4NgkpX8Xi/DcvgcL++ECgKYRjxdilw5HN4VSrOsq yob1eiT0a3rb8T+PBzYMacrkv++e8SFD2egnOTlVTcVl5Qgl4hWVBQbNMDOupGC02S5p KxAA== X-Gm-Message-State: APjAAAXPEaHZhuku6NSqhRc5DB80lO9yLBRWOCmCo8sTDWYBuQslk/HY mRnmYcT9km5LWz0SyAJdtco5xIiI X-Google-Smtp-Source: APXvYqz3U8A2I+j71gFAkgXW4AsB7Hi5eioGZbX/ykmHrg71E/PZFOpKO3hLu0Ep4ocVKsmpZ0F/XA== X-Received: by 2002:aa7:8a87:: with SMTP id a7mr7469839pfc.252.1553082447777; Wed, 20 Mar 2019 04:47:27 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id q86sm6321043pfi.171.2019.03.20.04.47.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:27 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:23 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 03/20] diff-parseopt: convert -z Date: Wed, 20 Mar 2019 18:46:46 +0700 Message-Id: <20190320114703.18659-4-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 3eace63172..f290dfe6be 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 whitespaces 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 Wed Mar 20 11:46:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861455 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 BC7B81390 for ; Wed, 20 Mar 2019 11:47:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A299E28ACA for ; Wed, 20 Mar 2019 11:47:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96BBE29ABB; Wed, 20 Mar 2019 11:47:34 +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 45FBB28ACA for ; Wed, 20 Mar 2019 11:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728031AbfCTLrd (ORCPT ); Wed, 20 Mar 2019 07:47:33 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41179 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLrd (ORCPT ); Wed, 20 Mar 2019 07:47:33 -0400 Received: by mail-pg1-f193.google.com with SMTP id k11so1620882pgb.8 for ; Wed, 20 Mar 2019 04:47:32 -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=rgW7cf+TDIhw9W2pz6ltAL4fzzg/Gw3bQuRPnD7TjUo=; b=D0uiE4w/FrEFQu9InagcdTOylPmMesXxW6LtEkh46HBPLysazV8iTDCP9PW+tDZwoY e3RSFjUQS8WeqmTPErd3H8sc9HeFzqFXzm2aC647TeBkC4kiZ5QHEWjr9IG84G7tLpKm 86rI0DLmn42f4th6zvfZts66BuHTLZ2629G+UGJGqEU6aVBxxpksJRQjrMowAtnMP30R b4ADWlqeofzFUN5XXFIfMozIhlZ81S5bMGq+ViVo5yKn/v2HcYWmo5cRg85naW29+u+M c5h7p/VN9WmAH/c0YaSIhhhEN4owMBa08DpG1cHlYC6sg4uDWTmXVWsFURt7eEHWQ28D n7hA== 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=rgW7cf+TDIhw9W2pz6ltAL4fzzg/Gw3bQuRPnD7TjUo=; b=Y930O1vxnWBedd6zW+nwvjdFZBLuC9x9mYkoNRSdKtHaYMkGIwxH5ZdUlNXicMd8Jm Linl/z11DXtG6uhOdxe2d3rumygGe9lNXtLRGbPyr3rLCVyG3sevnByKDgQm3AwXTSTo jwl125Qr4HAVSDAdyr1jAGzmXF5nUlhT7GJ/FXcsn96jjNK14/dnsixrPlDiNnABKX9A 1bvaTtDfwlGeBZFjvfncFF+Vw1ze8mLJXNE1dWoGRTk3hvxdpU4OIn7yhmFJEgCcxcb1 Wm2S0VaJkJQL++5+V52SJ6gl3Us7cSb9ZbB4aEJ4JbM2FuS8JJ9yqnIO7Z2xexys2sf9 dYyQ== X-Gm-Message-State: APjAAAUnzWKu9prZVe2mNHi26B8KG1JthRZYnIRpOmIi7pebvws8D7SD O6mU/yxqWptdj2tqVSMXTo7V356N X-Google-Smtp-Source: APXvYqyjrmHwZKZpiwMlHTuFQSVl4y6VFfBL6POAuVEH66aNZJoHcKh2RwQooEi3+WJAEbc/8t+ziQ== X-Received: by 2002:a17:902:e90b:: with SMTP id cs11mr7345209plb.197.1553082452382; Wed, 20 Mar 2019 04:47:32 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id 8sm6055935pfs.50.2019.03.20.04.47.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:31 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:28 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 04/20] diff-parseopt: convert -l Date: Wed, 20 Mar 2019 18:46:47 +0700 Message-Id: <20190320114703.18659-5-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 f290dfe6be..a2abc7e5b0 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 Wed Mar 20 11:46:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861457 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 069601390 for ; Wed, 20 Mar 2019 11:47:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA4728ACA for ; Wed, 20 Mar 2019 11:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3C25296E8; Wed, 20 Mar 2019 11:47:39 +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 795C4296B2 for ; Wed, 20 Mar 2019 11:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728039AbfCTLri (ORCPT ); Wed, 20 Mar 2019 07:47:38 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40936 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLrh (ORCPT ); Wed, 20 Mar 2019 07:47:37 -0400 Received: by mail-pg1-f193.google.com with SMTP id u9so1624199pgo.7 for ; Wed, 20 Mar 2019 04:47:37 -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=CsU0Amsn1GvYiiTtnCKDAoW2nSbPXGeHv/fXRKd5d4I=; b=R6uHzzGqOcehdVdcy3EQxbWWTAKm3YfLmNRZId8eGHpWoIWbD/xDzNyN/Bht2zh6jA pqXTszegfMtH/DHnFZZhmY/BqcxWrJqG+7/2zKSyJ6X6gKSyhJzbNCcD4dgGfGpuhjW0 IncvgTF6bI14Ry0xFSR//7ONZNNUbL2bNwSXzTNwqDKAFdifBJw0EZZfDfN58KMT3rZk HRltVb8SdyWrIFG2wblFKiWDfkNWxDnJs0qmx+8Ym298VRIWp1RxMZf7ri+IV5RVpqU+ a4jex6ouYKA/Pf/ueL3CBMIw6k3aivV8Wd6wZ10rRR/UVlxCBGV+qG3Vi0/+eQ3LadfM njDg== 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=CsU0Amsn1GvYiiTtnCKDAoW2nSbPXGeHv/fXRKd5d4I=; b=g0OQOFKpw0vSpYotl/WwcCPncotbIY0G9XXCsno7i/+dhgdtt+WtBrtMNcvwk7xCLd Eh9KFjLFe3g1dlK/wG5+1ygdLz1N20xkSgt+B/O3ENc+FZ2kkEiiqlPyJmust2n42qbr w7yiMPu3lxApF6mEMAvpj8ITc7ez7hP+ENAmaDhU+X0Xgk10e5m8maaqJ2fdr3w8HF3t 9PRSsaSQf4+HUk5cikhwdt55ykrky0o79iVPhpvAoTi6LS0EwXgjrtGs8RAMjWVJfNU4 rW9XsW/hNmZ1ITu1Pi+FXErM+2yUQbk+s4ksyPubFLj5j2Wo1P/W2GJLuxgQacgnSeiv cArw== X-Gm-Message-State: APjAAAXzJ7G5CavAmo8yAJSMDDJwSuLvUbiB3nnD55h7j4iUdOmcK4xt l52+Hv/cjdEXgWG4QIecJ3lRI/MB X-Google-Smtp-Source: APXvYqwqPrVVfGjWk7cKYlFV7ZBmiYcwgCUSZm4DvY4ryo0HSyMdMs5P21og3IAZFtd49SCh9GT40Q== X-Received: by 2002:a17:902:e912:: with SMTP id cs18mr2718173plb.130.1553082456957; Wed, 20 Mar 2019 04:47:36 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id r3sm4927369pgb.82.2019.03.20.04.47.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:36 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:32 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 05/20] diff-parseopt: convert -S|-G Date: Wed, 20 Mar 2019 18:46:48 +0700 Message-Id: <20190320114703.18659-6-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 a2abc7e5b0..e198129353 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 Wed Mar 20 11:46:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861459 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 7E9881390 for ; Wed, 20 Mar 2019 11:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6412F29B62 for ; Wed, 20 Mar 2019 11:47:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58B4029ABB; Wed, 20 Mar 2019 11:47:44 +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 0480D296B2 for ; Wed, 20 Mar 2019 11:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbfCTLrn (ORCPT ); Wed, 20 Mar 2019 07:47:43 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39328 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLrm (ORCPT ); Wed, 20 Mar 2019 07:47:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id h8so1628649pgp.6 for ; Wed, 20 Mar 2019 04:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bclt4gp93X0SrEfmrbRLAw6OgHLJVtWsJgwFVW8r35A=; b=saePxqEdpfqwnw368yTUo50RmBDhnXI0iPXugU+k+f9z7mfU8TXr4M+l5P6Glvj1bX zhD5kCiUv4p57toqxW3SzV3tGrrLIU8+Jfj8oQb2FFI99xnwrzdBq1DpjgEkAIPDd0sR +PvulP1Qxdo7C62i8Z+WG2hJyvdiYCKHDG13dzb00X3mhz2Z2aGlExVKXRq9oFCnU0vM 3ZqrUJcPYnI9jeX/GhyeQ7hOvIACyITIRIVkHr6si9t0xcHiO7CxAmJDoSCu8LWZCwza T53zIczcVaLLUTmZgRg1j176hptjXDOEFY3PMAfz3WmQFlvk9CdPhQms4NgWclfApA9F y9nQ== 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=Bclt4gp93X0SrEfmrbRLAw6OgHLJVtWsJgwFVW8r35A=; b=rKMzZeUwGE6uDZPCbRnmAe7lrpeAH/Wncn0oBOCaURCh6NbHSAI6vkmTL7aZLLiDyh 2koz6ZfNdZH8++nS9Cn4h3vK7YaaIEa/ZaH442QYDsM5px/OGZ3uBRuKOExrtVwD3oOD Kq7pLAJdQZEKJrShrTmgDd92pndDkx9f2wbrQJYf5awkQ7U5kxRjJg35rzxDKYlNjSK5 6W+XNlcMf0zzo7e0LbIcBS4l3jYDk+y2F70xFZdzmW79k+8a0eQ7MK5WaC729sRukEoH UeSZmhzmjL3GkO9TDoNwXj+DNZ16260SMncH3TepfrXVvpUuC5TJoxQAo6S31K+f3/6e DKWQ== X-Gm-Message-State: APjAAAVwvuyOr1eRfyVBzBxvLPNr9q9Xs25a/jA8xklZun3yhLuffPev qyS/d7w2J2gGYAmoPysLE5MWJJd3 X-Google-Smtp-Source: APXvYqwY/6Gw4+kNJdbje9AF2JS3Fqi7P25gpEy0rCW8Hxg5u3gzLdCtsl7HynsE9HfS//AfCdmrXw== X-Received: by 2002:a65:4145:: with SMTP id x5mr6855797pgp.144.1553082461577; Wed, 20 Mar 2019 04:47:41 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id t3sm2090841pgv.39.2019.03.20.04.47.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:40 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:37 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 06/20] diff-parseopt: convert --pickaxe-all|--pickaxe-regex Date: Wed, 20 Mar 2019 18:46:49 +0700 Message-Id: <20190320114703.18659-7-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 e198129353..639b166c79 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 Wed Mar 20 11:46:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861461 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 A264017EF for ; Wed, 20 Mar 2019 11:47:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87B9D296E9 for ; Wed, 20 Mar 2019 11:47:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C57629B5F; Wed, 20 Mar 2019 11:47:48 +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 2856C29ABB for ; Wed, 20 Mar 2019 11:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728045AbfCTLrr (ORCPT ); Wed, 20 Mar 2019 07:47:47 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46832 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLrq (ORCPT ); Wed, 20 Mar 2019 07:47:46 -0400 Received: by mail-pf1-f193.google.com with SMTP id 9so1511970pfj.13 for ; Wed, 20 Mar 2019 04:47:46 -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=7IWx4TK7SvmgrPfkxrrsRevfFq0UxYrwUkSqzRNSYpM=; b=piU0pN6HeTXqDT9vF3FIYHP2gynJB4eJ/79K2hoYZHoDkJ32TzpQUHCkU8roBeyUJ/ XESt9TQaVREfzRTdGQWAt5rSVdYCLyH4rSDN21YanVJ56iRQ96YxtW/Wdz1+1ZKyr06J MmNYVMlCLTE20Iqo3M/0frbcvzSY8NUNQbh6KHuD2zb5I3TMnDnf5klEZKJuwTvQQrGy buzKjPbMJW13BfDH3lApbky4VTXCfQoCklcANYS5rYhL4SnxTK/IWgjIMg/0/ZbRKGBk 1RsHdAXicSayCCYhHQqh3lIQwgFCRXoLK4Gm4QlflskwnonSuDbgbLrJkAp0x65xx5hO rA+A== 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=7IWx4TK7SvmgrPfkxrrsRevfFq0UxYrwUkSqzRNSYpM=; b=hO+OcAEsRt3gNntxNqMhR5LiNlLmsUDQiY/0szvtC5+qtrYaDSGgS/zVm9u3yzm+qB /f5tjBNSQi89x9pl/Co8NnLRxFvM+U7nlIEfPL+mI0zVvgHg2cGsTdYocaGDLRqgl4/0 aNNZOA1Kfw9hlXfbXmaU9x7FWmtfNbwsMhENqkJndUQTLfXzXa8p3H0SO/TA77c4Xc8Z 0IBf7uvwpedB8j4zfPoJieTrBQjQd7EM8tt8te54nsOTom0lMI2Q2aIn71e30EfHY7l/ OPnmWd9oQTHTlpsNOGdsoZIH7oC8BGizT75wed7JN7mD9lpTr6aGsZgw04N0NGwDcAFx HuQw== X-Gm-Message-State: APjAAAVtipbyjt+p3HWXOzwNy5bxgMRa03CDW8AYKrcr6EbzY+KEHKGy fmxXAnI6CNjtBP2o0YdMQRc5ZXEk X-Google-Smtp-Source: APXvYqxRVSgtTg2jR5ZYeamkjW0dSD5fxB9Z4LDqFj475LYi9wBtokzBmO4AO025ORxp+qnkAnmdLg== X-Received: by 2002:a17:902:f01:: with SMTP id 1mr7401128ply.41.1553082466131; Wed, 20 Mar 2019 04:47:46 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id r82sm4524599pfa.161.2019.03.20.04.47.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:45 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:41 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 07/20] diff-parseopt: convert -O Date: Wed, 20 Mar 2019 18:46:50 +0700 Message-Id: <20190320114703.18659-8-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 639b166c79..21c7a6b1a1 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_("override diff.orderFile configuration variable")), { 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 Wed Mar 20 11:46:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861463 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 0EAD615AC for ; Wed, 20 Mar 2019 11:47:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E750A296B2 for ; Wed, 20 Mar 2019 11:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC4BA29ABB; Wed, 20 Mar 2019 11:47: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 867F7296B2 for ; Wed, 20 Mar 2019 11:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbfCTLrv (ORCPT ); Wed, 20 Mar 2019 07:47:51 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34451 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLrv (ORCPT ); Wed, 20 Mar 2019 07:47:51 -0400 Received: by mail-pg1-f196.google.com with SMTP id v12so1645544pgq.1 for ; Wed, 20 Mar 2019 04:47:51 -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=Ny69466qpbMAXTND/J7eWaOTrxbSRgVmKce5SmOTcz4=; b=PuojoGt6sx1P34P5gdO8ZgrVK+ZeUE/mj1xvq+P8k/i9r160XLcT/KdEDadIvEh/Si 45yL9yAOX7nTW4oV907ohKeSPNTydlxtK35KE9AVZeWKRCxxwaQf6cyIX3XeclYobpOx plVKxkJBn9tcstFHIUlNY3A519RA2UpbOPXA9cU50aorRiQifxA3XKd9vbh4zzOmRlhg N4G2BY2wkaY/hRmIJ/WRZDs/MM7TeOZFCPD22PpOZpJ/mgtzFISYpqBrlZtRAZBcvGy9 Bmvt4ocX+MM98TMUIxrytRaGdfH7SZmb+zT7q44y9D9VTsXL6VmRaoxnvryqrABg3dDx 060w== 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=Ny69466qpbMAXTND/J7eWaOTrxbSRgVmKce5SmOTcz4=; b=HhJ9LLUgrIh6RA5Z5UdqB+OjRRv2/SxxfgAXjAPdk7C+8l24XWfpVAltRR6lw3U84u ENyTZMr607lkDYbS6ioywHr0MV3OvkirBY2fcHhPiHJMrXtmOMN5lMVhAgMiAey93M37 /Ga+ocm5CjCXkG5Ugw/8Yf+r2RwMxouVcewLoWjN4SxI2wjXd8qBwJ6c2Jz1tBgVKqIK Bn1spqOXOorsDmCes1pUHA13Kv4MsAdVilHoUyZquvm1nlLknWyRO8z9t2Ctf5tprGmu 5LjxxE4TCnz5BzvRrq48Vzf/oOvo6pCgu+GvV/lU8vubyIfYaoOAgxGSlYJGPylTgkAD VnHA== X-Gm-Message-State: APjAAAVZmfIlyvQNSlNHKu6ni2DVVlmpYApBaqNFXWTOZdlrKJkufwEe 7THOAd1cYG7kVHqHbSGsnDESSJeq X-Google-Smtp-Source: APXvYqwkzI34rsjJv1IusTHyGVMYpGbxgcjxvGTm4PU1h1AOJStSkFth30E3DQtkI1nEIJ0biB1oxw== X-Received: by 2002:a62:3585:: with SMTP id c127mr7543181pfa.71.1553082470691; Wed, 20 Mar 2019 04:47:50 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id n15sm6025694pgc.92.2019.03.20.04.47.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:50 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:46 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 08/20] diff-parseopt: convert --find-object Date: Wed, 20 Mar 2019 18:46:51 +0700 Message-Id: <20190320114703.18659-9-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 21c7a6b1a1..694f32148c 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_("override diff.orderFile configuration variable")), + 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 Wed Mar 20 11:46:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861465 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 8AED01390 for ; Wed, 20 Mar 2019 11:47:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C9C028ACA for ; Wed, 20 Mar 2019 11:47:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5794D29B67; Wed, 20 Mar 2019 11:47:58 +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 45C8128ACA for ; Wed, 20 Mar 2019 11:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbfCTLr4 (ORCPT ); Wed, 20 Mar 2019 07:47:56 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40412 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfCTLr4 (ORCPT ); Wed, 20 Mar 2019 07:47:56 -0400 Received: by mail-pf1-f196.google.com with SMTP id c207so1758745pfc.7 for ; Wed, 20 Mar 2019 04:47: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=2kK8ChyJmFBjAel14d7U+O4YZM/azRlI/kEK6OTFPwY=; b=JO4+yDEqFDnmCqUjmLQFtITseKqb9quE1LDPgHcps4JU9kMgPiK3P3DQ+U2Ch4A+mx zLgA7PJh4QSxG7A3jA6iWpyPuVB8vuDdSp6gsnrZcSyUn+zyaFJo7WbofCH8Pol0gFku 0Nw7NC+gKJl4Emt6S8HvTDc76gdSkOXXs8aUfdDMMxVzRyLaOU3D2ebdcwJzTDZ22a2a rqtrWYjNN8CV+2Ii/L2C1UW+ypqZbf2pGZhqrup4/mFid6GMHZwFzBEwry9DIKKP1+KS ZolMxqV00mQDtC9EZfABEk6KywnNSU95Xm5+rO1S3yppL923nPUCENJj14dDRlw4yxOV /b+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=2kK8ChyJmFBjAel14d7U+O4YZM/azRlI/kEK6OTFPwY=; b=UnIpgb7pW8RHzEavPpr44jzOL4n7loPtrXJHboy8PxMd/5jTZq10w2aVNy2+ed744Q nYXMVr7ZnctbsYvUW7oGqIiwMaW9/ctq5D8wDi4+tCWQmfdtIPJxU2zWSkD7zlSyzgKF vMEIBwMAGLJql6Y1jyCizFcFssZsD9m/naSqe2iEqyG+xK4tdE8Q4kwvdx7zTCnrOhjd 3E/ThhOdBDqLCEBHjFd+UuXPEAKenOd1E0mwIYvDwUH2Pl+dS7yy883ub9KuJ3m4PVtd x1l3mkAhV5CMI9pPYiwkN1itTU5eh0FEX1mBZ3fvOjfGpYABJK6I6n1BP3/GG4Pu/UJ0 5kYw== X-Gm-Message-State: APjAAAUmJCjpHByglHLiHjpnxawanKhdLjB8vZHiRpQrkzDMG4OyJGwt CoF2CLEiPihnwUoe06QsE9wFAkqH X-Google-Smtp-Source: APXvYqwSpviwDy+6pW0MRk+buAw5kO5MqcUC0ZXtQubkjEHTezyyV56tc0LyAO1LnudrTo5wDMopSQ== X-Received: by 2002:a62:f24e:: with SMTP id y14mr7305779pfl.209.1553082475282; Wed, 20 Mar 2019 04:47:55 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id v5sm6544024pgr.4.2019.03.20.04.47.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:54 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:50 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 09/20] diff-parseopt: convert --diff-filter Date: Wed, 20 Mar 2019 18:46:52 +0700 Message-Id: <20190320114703.18659-10-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 694f32148c..6e84af1cce 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 Wed Mar 20 11:46:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861467 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 C349E1390 for ; Wed, 20 Mar 2019 11:48:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8B4E296DB for ; Wed, 20 Mar 2019 11:48:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D1E329B55; Wed, 20 Mar 2019 11:48:02 +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 3DBCB296DB for ; Wed, 20 Mar 2019 11:48:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728055AbfCTLsB (ORCPT ); Wed, 20 Mar 2019 07:48:01 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38228 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbfCTLsA (ORCPT ); Wed, 20 Mar 2019 07:48:00 -0400 Received: by mail-pg1-f193.google.com with SMTP id v1so1630651pgi.5 for ; Wed, 20 Mar 2019 04:48:00 -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=Q3v2ruXFnKaKFsyGmZ9nply9ZmV5CHcqI22RwMdvPg4=; b=PtUeeG69JAXTbKJq3KfJr8MHsUfOJwLXLO4w3dmym1UImW/LCAD1bxMMZDGOKcdapo 5VHrH7yzaoVmtVU46DyUseCAyGiJ9+y+Ebwh0QJv+1ZWwpwG8ksR9HnxRCwipHLwPsX8 3w6ehnOONnuOk3hKd6/fk6ElNbK+QDieE98plg9iUmP4qKosZFGspkfXnweFSa//6tWi tTOIaAH+0J1MgoWeNld23VEG4NaqmR4GVkkdLgN/qR769OpsqTtV5N5qLB9eo8prXJZc SW0mfWTA1100PaJxOZC5WvjXXHDahKeFhSrsHitTi3pqQIeJVrdLffFBfNckm4dTZWA5 8tLw== 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=Q3v2ruXFnKaKFsyGmZ9nply9ZmV5CHcqI22RwMdvPg4=; b=HjvgfyhCg+LzuHqh1FNHaH3KqSqH2lxJbla9TG0ij3HMfx/BuQCS8tHc8zoiycCvOq zeJ/r26hfQeFHhzMKCeBeIuLNSkH4tBG0xaKa9A0OnjSywswcslPJT+H3EDK2DCeJZ3Q UA3QM9ioRTtTdt63eP8zNG5TOh8UEzx3AETxjkDguV43wwpkTeKZHcc3Ly4YrmlNKMvU X3aotIeuThD4hz5k0cekj/NM6gu0A3SEggNkH83dxhB1q5jOHsUO4vBKPzoXiTQYaVq/ Ol57EdnmuichbWgWXJ0GMTd0l/7HMF9A/Bi0PDxswoBPR7RxwG0cpKl+cpqK7UFJHmCn cgtw== X-Gm-Message-State: APjAAAXP77er0Vb8Ql+uSKNOvqopt5poKODfqkIPSYp5o+OhflGMo0tk pOAsB6Ywp6cvwdnarxAWuUPKcXBp X-Google-Smtp-Source: APXvYqw+/VDSTu26K5OmxImVV0N5wfV12Ugxy2tggTpmoUWQgnbIwJ6Va36eN2sWG/8+XPdoGV/RiA== X-Received: by 2002:a17:902:a511:: with SMTP id s17mr7953647plq.262.1553082479931; Wed, 20 Mar 2019 04:47:59 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id m79sm4661848pfi.60.2019.03.20.04.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:47:59 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:47:55 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 10/20] diff-parseopt: convert --[no-]abbrev Date: Wed, 20 Mar 2019 18:46:53 +0700 Message-Id: <20190320114703.18659-11-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 6e84af1cce..30baf21021 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 Wed Mar 20 11:46:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10861469 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 1F4121390 for ; Wed, 20 Mar 2019 11:48:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0468629ABB for ; Wed, 20 Mar 2019 11:48:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED1CE29B5F; Wed, 20 Mar 2019 11:48: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 89D1D29B55 for ; Wed, 20 Mar 2019 11:48:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbfCTLsF (ORCPT ); Wed, 20 Mar 2019 07:48:05 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32768 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbfCTLsF (ORCPT ); Wed, 20 Mar 2019 07:48:05 -0400 Received: by mail-pg1-f195.google.com with SMTP id b12so1655618pgk.0 for ; Wed, 20 Mar 2019 04:48: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=6lui7fnu0IRlrp71D2hv/7mB2c92uRxIs2duLtUJCr4=; b=FQyDIy/3Qy7+WAByBOD0lNoBY6Nz+6v9RvzkYzh70jGvA4hGeWH7MH8Hgvs6EWJAoC yOQaEvFaPUGniGqyCPDmGHzVn5E6ipT0+BKPuE+dVXz3n1dlb3nkUWFv8tiswIQWwQKD QYi+1zoh+8/lS6dAmNeRZgCszc7j0nse4SR87rwGoYSzvART8qYuksDcjPCnYkY8VtRV r6HB6vIkTf3L2qDcZfJ5Zv2J/pO3tJtTuWKgu8GsPo2vq5DnxNO9xiU16Vjkt17qtZ/g N/YbNIRuzBz1J8jiGol1xOy1PHOfbQgiO0N4sddQPUE4nhB9fybXi+uekFO4bZLrGpmb drFQ== 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=6lui7fnu0IRlrp71D2hv/7mB2c92uRxIs2duLtUJCr4=; b=muVyJpxfVpke7FgoG0XHRAmFZfXwbZxyW0X8o5RO2+2NL6iyf5vx878EeRlzTHpHeW w0pQadwbsOmhsXnyLcjnKOV+HdmxUnSxvvmJTbQRKwQPBy6/++wiaSoQb9p5tY0FiCwK hWqyBmenLXHM3UDf8exB3l1OlwDRS3d8COfQB/Af3B8qwOP20Q1iaAqM34+91+iSn+HE RX/EdDzfWNPaXCSaCC4d8hhrwbpCLvkrCVUMLrgzLGQHtFMsB9qSi5b+0yYL2nVd6PnF Uf2cYDt9JxQ0drMZs6sa5wTzUDODW3NAP7Juj2cU7QGPuBs4/EEO7Gniax5HmlNorgj5 ltRw== X-Gm-Message-State: APjAAAXINSulzU05slLz0SSEw3QQnP9LhidPTx2HBRNdCom2XOplh4yW EZonweW5i7dMBJXrRLl7R0toRB/m X-Google-Smtp-Source: APXvYqzHgWqY9k0adCl/Vvhtrnhf1oJO8DrbmmigGvJr2zN4EVM/BCCbfeioo2Nw0N1ceb+oJ/QiMg== X-Received: by 2002:a62:b25d:: with SMTP id x90mr11856284pfe.102.1553082484503; Wed, 20 Mar 2019 04:48:04 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id f4sm2085392pgq.94.2019.03.20.04.48.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:03 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:00 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 11/20] diff-parseopt: convert --[src|dst]-prefix Date: Wed, 20 Mar 2019 18:46:54 +0700 Message-Id: <20190320114703.18659-12-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 30baf21021..2d34dc878e 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 Wed Mar 20 11:46: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: 10861471 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 D4A391390 for ; Wed, 20 Mar 2019 11:48:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA0DF296E8 for ; Wed, 20 Mar 2019 11:48:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE61329B5F; Wed, 20 Mar 2019 11:48:11 +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 5BEF7296E8 for ; Wed, 20 Mar 2019 11:48:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbfCTLsK (ORCPT ); Wed, 20 Mar 2019 07:48:10 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46106 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728001AbfCTLsK (ORCPT ); Wed, 20 Mar 2019 07:48:10 -0400 Received: by mail-pg1-f196.google.com with SMTP id a22so1600969pgg.13 for ; Wed, 20 Mar 2019 04:48: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=q6nHeR93jYKq3cxlL9ndQqi0yjDcun/sOOhJQPnOB7I=; b=RoN2KNSM2KeKwXAjUn5S3BIeXk2L6sMbZeWgLtbOLvFXCGvnBsiTq4qp+0rN6GREIB Craz5+GEIeZe+OZi4u7Ace6yXz4s3+6R0iXYxSHuejaCREY+/t8d4gpiS7ynpfmAiHul 6XHSyC+83xZz+x6Ie/HEsmvoOj1ZKmwZCxHz1f3q5KY4FsLxmmczAaFHqEqiQxGSM4TO 710NmNPmr8tL1GV9nUYCVjDIEf5AG7ZDknHHiBe0zkPM7erBPACXtcrz1pyi6qvbsqp4 gOUdomM2wAxc8OgIvM/CZrJ6YR2iNfslMXSQOWUpsDPa3rIB+0oJoV7poQwGDN/ajVvV H0SQ== 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=q6nHeR93jYKq3cxlL9ndQqi0yjDcun/sOOhJQPnOB7I=; b=nfM8Xm3VVPcp1e4ZinPdG7JY+pASjmTr7fbxu0ikugJFM3IR4PcoMNQdf5HkTMsKYP SkrPPSDY/dHjUpw8O4V1b21w7xTSn0iCh78TLESkcjcfnv/vgdVVBw01zm85Zb3F5lfK mWukmcqDm3O4by2qelmwUB2B2q74iU7/1yEtya3G/jqX3DA7OJc8ZwElGLbxTIC1alC7 jKB5noi3SPIKbZ04nlUT+oyteEG3zNbelIOBqBvD7tm+u5EP3+QnracY3AS9VJa4Op+a ff1wVB1EEVpxIkZ6COtuPo4PvfZ0PQJ8JTEI3fkBgMFlYn5Am/ZiqMc+CiXCXjKqj1AN /Aqg== X-Gm-Message-State: APjAAAXQHTR+0vL2eboJdbpKbE2Ew/QQomaIzHTWYIt9rRMots7OwsKA +4GCWjs8D9wK+cc/A0NeDARQ5kw/ X-Google-Smtp-Source: APXvYqwTQZdxnU1erb95Geujdkfw85Gqp0D1camMDCn1iOVbs+A100H12EQfjKmTBZQ9DdOnhOqK3g== X-Received: by 2002:a65:6656:: with SMTP id z22mr6642924pgv.95.1553082489080; Wed, 20 Mar 2019 04:48:09 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id l184sm3091701pfc.41.2019.03.20.04.48.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:08 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:04 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 12/20] diff-parseopt: convert --line-prefix Date: Wed, 20 Mar 2019 18:46:55 +0700 Message-Id: <20190320114703.18659-13-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 2d34dc878e..4ab5b3c06a 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 Wed Mar 20 11:46: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: 10861473 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 96EEA1390 for ; Wed, 20 Mar 2019 11:48:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C4AA28ACA for ; Wed, 20 Mar 2019 11:48:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70AB729ABB; Wed, 20 Mar 2019 11:48: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 2095128ACA for ; Wed, 20 Mar 2019 11:48:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728063AbfCTLsP (ORCPT ); Wed, 20 Mar 2019 07:48:15 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33481 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728001AbfCTLsO (ORCPT ); Wed, 20 Mar 2019 07:48:14 -0400 Received: by mail-pf1-f195.google.com with SMTP id i19so1780885pfd.0 for ; Wed, 20 Mar 2019 04:48: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=rZPnPdvuhrNvtya1bPytGdmJkP/s5w0ac7YcgyJxi3Q=; b=F6v6XzUik9K9lfXVjgM8T+/sjlIDPPyjpSXmDFSDQPRdMeQBBNOajDd64wzlM9GVtJ 5RUcEdUPa9zbnLG2Nu1S9HUZHwBHXMK01JT9FLRlo3zuwRi2eAkqeMTxBr1sOgMmLc9x 42as++IEwlwFEG7ehe6H8efkBYwDYrVH9SoS7bw7cizLegEY4vAXz3zzZyXcIyYD5M0s qfYm23HKNMiUArZYprnB+J/27DDinK617q4dYyQjq64Qy16h8FB+RCBmmqaKFj7RUz8D SmwWgADVEHDFwBfkMSvEJa8Ye0hS/UIfJ2ViYWlTFc760oL033lYidoy1Og5xJAA/w0f 4MSQ== 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=rZPnPdvuhrNvtya1bPytGdmJkP/s5w0ac7YcgyJxi3Q=; b=Ahqea8rdGAJv9CGjOjNmOxzX1vlmT8tH5Y/CXBguhGv8XiJUmIW6Gv6J2nJi13Nyry hxRuC+svf03VLPqyly3hLq/3mwIm8eOtD8tfpZNKZEgxRRnqmwTN9LcH9EZ7MJqd8KvX lqjXjomuKQx4v5rzDvuooZXCMVXcNi3BpuOcXuz7yM3oI6Joraau+uLw7cpSaVH0sK+v WA2jw7XjFqFqlxsHJWOcWkdBLd8Gii2dDxImdbcWYa/08B4BDoAovCUtWyhI+y67AHuB UVBC5TzoZBw6+LNSHhiZpsUB67fWlQjJVYgpwLuK0QxujM3b4vZ59kD2Q2IsUNDbJGKb DaVg== X-Gm-Message-State: APjAAAWc3fh3niVMLID62bKEHkZgCkfetBrnlF86kEzZ/55fOlr2rlkm 7cbVFlraisFLTk/xOxL+wiUBfMK1 X-Google-Smtp-Source: APXvYqwnnBbXuEn0mBbhXXUxMWUEYbSxfLa3S3qaKBI0BXG6vM9VTIXI1fykj4cBAPeyDwKIUB9h2w== X-Received: by 2002:a17:902:d24:: with SMTP id 33mr23325517plu.246.1553082493735; Wed, 20 Mar 2019 04:48:13 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id a7sm2337909pfc.45.2019.03.20.04.48.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:13 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:09 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 13/20] diff-parseopt: convert --no-prefix Date: Wed, 20 Mar 2019 18:46:56 +0700 Message-Id: <20190320114703.18659-14-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 4ab5b3c06a..045fdbb882 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_("no 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 Wed Mar 20 11:46: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: 10861475 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 34B7115AC for ; Wed, 20 Mar 2019 11:48:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AA36296E9 for ; Wed, 20 Mar 2019 11:48:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ED0329B62; Wed, 20 Mar 2019 11:48:21 +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 5B1C4296E9 for ; Wed, 20 Mar 2019 11:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728066AbfCTLsT (ORCPT ); Wed, 20 Mar 2019 07:48:19 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46118 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728001AbfCTLsT (ORCPT ); Wed, 20 Mar 2019 07:48:19 -0400 Received: by mail-pg1-f193.google.com with SMTP id a22so1601223pgg.13 for ; Wed, 20 Mar 2019 04:48:18 -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=hl1MYv/C99BXMxMuwnnnjgPAR5zH8sVRZuOmRuaQ0Bs=; b=QUqc5PGyQm2apFs37kJboFSl/gLo0ffxU3btkyjUTGct+PV29wQcZmPfM6YD+RCrGS np/5m7w6ptxsR66b2MB7hdELNEkVjOJ6jHCQELXY5g3Cc7DKHL5IaW7Q1ysfhhHxaY4J P+ufB/kgFW5d0geStaRQe8bgfIcC1w9hDsh3OUzS4IEyLLHxdwwtmewRbJnwg2pxHreK PnMpSE9Kn7J/BSjlntkMYC2pLEXVjYwoGIcer7VeBh19z2J+UWf+VMhzsQr/cq8Y+qYP 5bQxQioSmhTFAVBNfBMILcuqRtZJzgyluc9C6V2/BvqGQD1WgF8cI7pnE7Qo7qKsvYjO X46g== 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=hl1MYv/C99BXMxMuwnnnjgPAR5zH8sVRZuOmRuaQ0Bs=; b=QNdiAOCpANoLgJVgqUpZuZ7JFW5dk51aeHnvGOGD5hWAPHIwwYtUU70mg8TlHM9Tkh 4u4rsLK/cAegpLDmPauxq44nBd5P5dZQrYXOs22pD015n8ZhFxJ4mNH/HOGURhzgnObn nXWMYGKxsBs5WLr/8bEg7t9sVUiYcPh0XmNlzT4vLwknWyRDHE0ioB2S8Blk64vLJEpY O3bEOkTYrIjeePIPAqjPc2uPQKpPbSXw8LR9VqQH4jumuFOopVy/ExIqhFCeTJmlQGrZ oQ29XXIEtw+ZhpsUU/J1kzb2MkCJ0+ENFnvSjvOdPeY1XCqXGB6OCMYJSyEpCNlM8W5w 2LDQ== X-Gm-Message-State: APjAAAXzs8J7veNfIjTbDzNFVd76EVL5lKtGFNp+QAFaZqfuNZwAatp6 iEaLpQ/kAWcSTq/TosBg4IHrVIBo X-Google-Smtp-Source: APXvYqyA8Y0SI9I2Fq3jcflYQzZlv+axLm3QoSIdDzaeYWPMhc1uUQRVe3W+QsZO86jWsi+o1ftZZQ== X-Received: by 2002:a65:614f:: with SMTP id o15mr355869pgv.383.1553082498228; Wed, 20 Mar 2019 04:48:18 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id d3sm2398423pfc.125.2019.03.20.04.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:17 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:14 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 14/20] diff-parseopt: convert --inter-hunk-context Date: Wed, 20 Mar 2019 18:46:57 +0700 Message-Id: <20190320114703.18659-15-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 045fdbb882..e2f515a7da 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_("no 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 Wed Mar 20 11:46: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: 10861477 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 7961015AC for ; Wed, 20 Mar 2019 11:48:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E7F929ABB for ; Wed, 20 Mar 2019 11:48:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50810296E9; Wed, 20 Mar 2019 11:48:25 +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 E9A63296E9 for ; Wed, 20 Mar 2019 11:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728070AbfCTLsX (ORCPT ); Wed, 20 Mar 2019 07:48:23 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44611 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728001AbfCTLsX (ORCPT ); Wed, 20 Mar 2019 07:48:23 -0400 Received: by mail-pg1-f194.google.com with SMTP id i2so1612845pgj.11 for ; Wed, 20 Mar 2019 04:48:23 -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=iEdc+TLMQta/9G9RdwgLqc6bxNNB5pITbowTKdj97y0=; b=QGCCaT2LgJo2Ht/x8VhyFq44pM2NMYecFtp/I8qF0cuHsMxa+YneBQxHXUtJynRzGi A+fPny6c88DrRVFD0y/0/I9cnv441SNtyp/ByXy0L1xoRiiviXWhuH8lEOJ+uFVTyiVG 6KiYl4G7F97lvpmpdgsm/rdYLnf7IB9BGX28tI7lCsCNJnwsynw+hSZ0/uITZZE4cWGv RL1YYKBjvLZSeqb6LQzEYoMtriSw0mnZlHZE4gUXDknqNepGD8QATskFg/eG+cEP2zfi 7Sc/k7OnaQDMNg6vwTht2PsZghwN+7w+pXrhU1efxzWSuGce+PiQaQXvSWAT0DSrapQu wDRw== 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=iEdc+TLMQta/9G9RdwgLqc6bxNNB5pITbowTKdj97y0=; b=uBwMyHAztSE21eir0GYpslr3lqqEqDtaAiNhvFXRllYY/orsQH6sCqcIFyPgEwD+vh /9VQnDnUuyEKQV+RdJhZK0AOdOSlBatA54XdFuvRbPzYSwb72cWmOIevGJl6wsKyQopB kZYzWqdsQQ1sRagRWwIaFc3Mr7UD3juRe9yax25J/81rasfxKGpwVljOa/lg70xQnv84 AX9QAfO/JqBIG5oldhhdfFPJROxNYQjZ7eg0tbaiFRjC5WYah4xs94qXakdxR10CxEnX X/SWAY0bxeCIevl6og1/hgjJZNlEmeVDJLfiy7PXvUfNnhmEQTsSvqVHb6zZKViJC/DR /WtQ== X-Gm-Message-State: APjAAAV9I8JSnXSfxV9TWcej+rBWdgYmmMrLnJPiGL5cD0In7fgl2MeT GK3pkRaMkD8o3C8UJUcmfaNLcKi4 X-Google-Smtp-Source: APXvYqyAHb/qCgNJFx7q7A0SPV0XTxqHflTFh8atE5UckaoQhwYySlPU9EoiqASQH/SNWKIojZl/fw== X-Received: by 2002:aa7:9397:: with SMTP id t23mr1019424pfe.238.1553082502943; Wed, 20 Mar 2019 04:48:22 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id 185sm2612925pfd.128.2019.03.20.04.48.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:22 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:18 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 15/20] diff-parseopt: convert --[no-]color-moved Date: Wed, 20 Mar 2019 18:46:58 +0700 Message-Id: <20190320114703.18659-16-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 e2f515a7da..df4303de4e 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 Wed Mar 20 11:46: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: 10861479 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 6A9061390 for ; Wed, 20 Mar 2019 11:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5052629ABB for ; Wed, 20 Mar 2019 11:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44BFE29B62; Wed, 20 Mar 2019 11:48: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 E222329ABB for ; Wed, 20 Mar 2019 11:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728072AbfCTLs3 (ORCPT ); Wed, 20 Mar 2019 07:48:29 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35536 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727999AbfCTLs2 (ORCPT ); Wed, 20 Mar 2019 07:48:28 -0400 Received: by mail-pf1-f195.google.com with SMTP id t21so1012746pfe.2 for ; Wed, 20 Mar 2019 04:48:28 -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=mh8IM9fTDqyX1iZQGxO8ovgcxzmHNO6gHoZ8A45dVOg=; b=mGld6v+kHVFE11l9hU4dXUlw9/gTRvCjhnbvpjFzjKZORWgMoucSVRiq74TdiMACr/ X8J1ixn88vD1MCknSbjTMEDdP3sUU10q6RMWWthcg2GQdKDKEELAnbpDVQ8NczNMIFix /nY9QxasqnX8o72CoCieOtdBL2NwGoFqb67v+XGUa9kRGUX2AVAmNRZAjN/hcvOFiB9L MPyLemLIIPaAjbc+EgdbfUN3rVDgR9Zs9AKxqoyYSJo5KlR5zZLy9y9X6PPHCLe2gL/Z WSNcIIncRmnJeCHvxxgFmw3xP/YPXkFyyaevznC4zH+HZzAJY3/Uuf+cwndmmZ7DW3hT ixcQ== 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=mh8IM9fTDqyX1iZQGxO8ovgcxzmHNO6gHoZ8A45dVOg=; b=JzhcF8DbISBan3wdRzxq9lXlVWrtPQg69x/BV3x3A45GVEQChyyvaUtDVJ/HKxhfQr dGYOZnwfLiV9rmAM6SJoZ7ny4fCbyGQRo/RFnPGNvryHNphgavJUWqmmQpPLz5olhgUw VbYeyk7PBAnEIEwqHzo+WGzEUjDbUso2bS1hoq9Qysjtpinmy47Xh1rIMSIwGbeaw2rW nWerSL/OgR8iQ2tKhZAcO1q/bkBB+ijZEH1Y0L8A27ji9T9gL2f3ggH7XMvmy49bn6ja sYcGKzrGUXsW04kzP0c3LNudhn3ZP77FBoXQK7U/cagF4xMmAz/Hl8M4E3GP1524RAQW 9aew== X-Gm-Message-State: APjAAAWpXnrIQReS4WLVgP83wcWmXDfuGqbyPOT17d/fgiHRZlHahkrw rjDXzIlmJjBhxUd0okeg1OjDWGIg X-Google-Smtp-Source: APXvYqyOoY0LE8RkPSVay/iCg5UnQJIL492u1N5dvvwktLovsSuOhrT0TaYfnSYpvSJzGfrCoZwmGA== X-Received: by 2002:a62:a50c:: with SMTP id v12mr7845464pfm.206.1553082507930; Wed, 20 Mar 2019 04:48:27 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id l3sm2239352pgj.22.2019.03.20.04.48.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:27 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:23 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 16/20] diff-parseopt: convert --color-moved-ws Date: Wed, 20 Mar 2019 18:46:59 +0700 Message-Id: <20190320114703.18659-17-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 df4303de4e..8f79d3f002 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 Wed Mar 20 11:47: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: 10861481 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 45BA815AC for ; Wed, 20 Mar 2019 11:48:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C26728A1F for ; Wed, 20 Mar 2019 11:48:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20653296E9; Wed, 20 Mar 2019 11:48: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 C3A1F28A1F for ; Wed, 20 Mar 2019 11:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728074AbfCTLsd (ORCPT ); Wed, 20 Mar 2019 07:48:33 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35543 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727921AbfCTLsd (ORCPT ); Wed, 20 Mar 2019 07:48:33 -0400 Received: by mail-pf1-f193.google.com with SMTP id t21so1012850pfe.2 for ; Wed, 20 Mar 2019 04:48: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=9BmWPilqglEsaEmy0glCNo+Q/095fnq1EKmnSUkEezQ=; b=EQ3e0T+upeCTLlubTlKdgyYJaOPEivUSJEhHX8ZCHXKFkdl8l6WG1kTOf2p5Bzbsl3 kchm27ZPD6DuWgmVmJvNKfFTPJXjStpwIHfnPTLqdCKZpEP19pVyvQFszgeODAfDU5rh rGUJsmcZdnYFa4t1uVhJeNoD3+gDzc5a73gqy271FG8uTFhqWljs/1CJ/fMAphzsROQN pxAjqQYZA9j4TT72dSz/qGNagJxYFVae/nUrS/rxjsWfzWaPDYXAwa2cmY6vCJNu7CCm pknwcAWatjlbhRdE4VjevRkAsz7RNeqjwxQ2Nn6Ppg3ThoQcGKNSmCZPWXW/tua4ZTP2 1LjA== 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=9BmWPilqglEsaEmy0glCNo+Q/095fnq1EKmnSUkEezQ=; b=A6z6xitaDjAIvW9znWGcSYXDokR9pfa46zJlwVsh1QUzJmWVfbBKwVlE761cFddL5n DMNUKNFej+VpfDg4OYz2rRfEAoyeomhfCzoG/CtHk2Nbz/C91znq7E5jFCSu6+hMoGds fjyprVi1iMwm458FOL/FvUWqjVkBxJUxtWgQYsU/An9yOaLeXgmklN/Sv0F0hPus9/Q1 OsFr/JfZ/5x8uAWqH9wRXFKN41ylUfBOOOJa6saKXzwsnvH6uO+xrbcvv/U4Cu4t6sC+ zUfTCmx/9XXQHDqkUp5wxE5FABlMZ4L/DYgybdXgJYgaJHJo6x8IuX84HwmuG5nquzlA NgcA== X-Gm-Message-State: APjAAAU0hFHfJUStfN9ma3L7N3Mb2ZwVTP4lpd4dGWkXRdeD9n1neot3 iwHKNi/INNjJeEP4ML77Bd+KvjiV X-Google-Smtp-Source: APXvYqyQYyberRPszOEQbsvJJ6NkjJieepWhqa+wLe3NjcBB3mF3yyKCWIjwKDQLk94sIj6uxhkysA== X-Received: by 2002:aa7:82d9:: with SMTP id f25mr7604008pfn.45.1553082512611; Wed, 20 Mar 2019 04:48:32 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id o7sm6060742pfi.105.2019.03.20.04.48.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:31 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:28 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 17/20] diff.c: allow --no-color-moved-ws Date: Wed, 20 Mar 2019 18:47:00 +0700 Message-Id: <20190320114703.18659-18-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 8f79d3f002..6ce59d0621 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 Wed Mar 20 11:47: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: 10861483 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 B30971390 for ; Wed, 20 Mar 2019 11:48:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9997B28A1F for ; Wed, 20 Mar 2019 11:48:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E01B296E9; Wed, 20 Mar 2019 11:48:39 +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 2FD7F28A1F for ; Wed, 20 Mar 2019 11:48:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbfCTLsi (ORCPT ); Wed, 20 Mar 2019 07:48:38 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37109 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbfCTLsh (ORCPT ); Wed, 20 Mar 2019 07:48:37 -0400 Received: by mail-pf1-f196.google.com with SMTP id 8so1772441pfr.4 for ; Wed, 20 Mar 2019 04:48:37 -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=P6frXlsD/p2h+4Z1YxW5np+pQsI4sc5k2ZMnK7kLvjsDbuGkToLY4SVR0Eo7CqRhKO XXJASX0pr2D1lL1Saw67KHxQPm1gGGJ59yE+wgwNzjg8Qgy2QWv6rs6GDT4ou/EA7EQH rZG0Q2Zsn6APsP1uHPFwprkYolAJNg1I6N30w+0zbmRSG4qo2fyhPGIm8F/yK8Jlhfr3 lG1JGSYAMZKMYo/a9CT6lE5vlaKj9TWLF8644g9mDJoy1GEH5puQgEqy8luyTcs+Mj+y s/FIUN7HSGzEbCLf0vpALJOMRm9ld8CUPeMvgfBj7wOgDv48++Gv56kCGr7RT74NAbvR W/JA== 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=ugaGQ6UlgUmyX3R+RSJYHgEAtUxod70bUJnh7uPq+JObdr3hpzO5lhhsS6/A0hCXNy Vg8W+E/eOC5ewR4mICgQaT23Qvix9KDFjdXO7dmkD2mxBjLKekeGp2h7XmuuLNopWFBg 0b8jlOdnlFXnufcttKTlL3KUSRULnns2RruGD6aKhaIFk3VK37Lwdlb57WXgkQtDczti +On3aT9EyaLS5QVLhuCdHXghEpSjgYQzh1t4Mtpm9ufYGuTQwwqlx1DlyDQ9FYt7g618 admZnNt9aBg9u6f/mQwUgvvBuKOwoC6uqnv+Y7wmD59te3TQNDxrdwsXzEw3+nrqs7YB qA+A== X-Gm-Message-State: APjAAAV4OuVTEzIKrdAhpR2cllJIfFMhFvhCTce9jNby0zX7evrYtwMh 8wJVQ66sc3awZtqNcmBKKFUQ6K6S X-Google-Smtp-Source: APXvYqweyYSagxv6cMM1yZYFn0hAKEkj8T0hgQD9IfVB5lVyaxJEVTvCRxBMuAArEJEn/y4TOLJTOg== X-Received: by 2002:a17:902:29aa:: with SMTP id h39mr7871226plb.190.1553082517256; Wed, 20 Mar 2019 04:48:37 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id i126sm3704530pfc.101.2019.03.20.04.48.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:36 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:32 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 18/20] range-diff: use parse_options() instead of diff_opt_parse() Date: Wed, 20 Mar 2019 18:47:01 +0700 Message-Id: <20190320114703.18659-19-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 Wed Mar 20 11:47: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: 10861485 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 2625C1390 for ; Wed, 20 Mar 2019 11:48:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C76428A1F for ; Wed, 20 Mar 2019 11:48:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00902296E9; Wed, 20 Mar 2019 11:48:44 +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 741E928A1F for ; Wed, 20 Mar 2019 11:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728079AbfCTLsn (ORCPT ); Wed, 20 Mar 2019 07:48:43 -0400 Received: from mail-pf1-f182.google.com ([209.85.210.182]:35928 "EHLO mail-pf1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbfCTLsn (ORCPT ); Wed, 20 Mar 2019 07:48:43 -0400 Received: by mail-pf1-f182.google.com with SMTP id p10so1773901pff.3 for ; Wed, 20 Mar 2019 04:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vsSDRcoBc73cq8zBNzh03Mr5G+WB2dtVwogFKvxBObw=; b=ezgO11aLEj4ro0Fshbm4jbkBEIfP2sRwvTfy6DJ019DrOUCNFyE6n2vR1mgswHqmkc 7yoVrgg+TFeFENQ5QH7cTAsGpoZ+hmS0XjZuWNaQzhSC1dzdRa9D414aF2il7p2+O4VH jY2/0Ti9RLQPqXqKDMQ/zFPRyPHE7Oe0/XXcLRwoJQeSEorL610KWpcN9qWxpypmyrIm QWT0ym2yjD1wB9v3List8BaPH1ZI8Lz5uP3TmUhOv8goF80zsas8gl+QOteookzWe0fk JPdI98MuMZ/OqxANJGcVaQq/vQ1v/pjr3OZTVuhrMCRiZ6BdJu2VQRP5oFQDa59W/CMl DZwA== 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=SyoY/10IfeM3L9lcNj/1q2kr5yBKNhnbzgkGjkO+RshAJenx9+/XgvcDroXvUqlnBe b2k/ofxBayBqF8jfY0XHrb8E0vOnG/PDSYyc/V3gnAFgMgO8eVmWxUAFRYmTzlagRj5e Iqn2V87hw4wPaNaBRaC6HIsmXdbblK0AiG/zus7y8D7T47FLm/UVkXd4GOGNsBOVuCtx +kFDV3uIfXxfTLO5ZlsdCjwSmxSTcXRhv8DbwzIaZw8eCXudW/JXaHu08djMCXJ5h+2k JlXzu4ajCy2i8T36bNVOGZVy6+m2RedHPZzQ8Og6A0+nQ/dWyTkulDrYT5z8Um+0CdsU gG7Q== X-Gm-Message-State: APjAAAUwCzVSCxVkV2Ftv/loBCkJezMVmhRRpxsVeSBlRxGY5YneguYB echpn74twmOxwuvT3QJm65fTTUxf X-Google-Smtp-Source: APXvYqwdGX1FmSqgfeMrBjXdKpQcHbKQ3DnEuY1nakcreaZ/aFjoBjhNK9qqo1YSpnc+qpoSRe0mTA== X-Received: by 2002:a17:902:bb86:: with SMTP id m6mr7623627pls.4.1553082521934; Wed, 20 Mar 2019 04:48:41 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id r6sm2345141pgp.46.2019.03.20.04.48.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:41 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:37 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 19/20] diff --no-index: use parse_options() instead of diff_opt_parse() Date: Wed, 20 Mar 2019 18:47:02 +0700 Message-Id: <20190320114703.18659-20-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 Wed Mar 20 11:47: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: 10861487 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 2909615AC for ; Wed, 20 Mar 2019 11:48:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E2A828A1F for ; Wed, 20 Mar 2019 11:48:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02850296E8; Wed, 20 Mar 2019 11:48:48 +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 9BAAB28A1F for ; Wed, 20 Mar 2019 11:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728082AbfCTLsr (ORCPT ); Wed, 20 Mar 2019 07:48:47 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44658 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbfCTLsr (ORCPT ); Wed, 20 Mar 2019 07:48:47 -0400 Received: by mail-pg1-f195.google.com with SMTP id i2so1613508pgj.11 for ; Wed, 20 Mar 2019 04:48:47 -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=8MnQAgwz1pETAj1BbOdXqyA1Mttd/Yiu1lyBHoMlD6Q=; b=R66oilwN/7wnb5npzhOXVZ62hmO63/7CX1UeOOv88gbAJqzVc5hI9KbKN8IAcsUkjo /kAEMIKsGTJH91FZ2itUke4zotWSfqh2FE7u+TFX1C1/rjCGNrJs8DFNt7LHPeedrDXk 4TP7bj0LKrIXEQ/34Z8ISTtkWpcOxXnBiTF0L5VE6cP1cFlqwUwdDZ94FW6j5RxbR6SC KNYdc+Ou7m79KTrsHzE2mkxv9XNZXCNfmkUPXmYl+DmbO1S2iu0cr8NJdmZiJb2xkrFq Aiaaw5fQcqwwQu0f1LqTsPzeo6GLJPFcGje8ZmIQIQxw3yVH1488iVZLlFHxOuAXAAoJ p5pw== 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=8MnQAgwz1pETAj1BbOdXqyA1Mttd/Yiu1lyBHoMlD6Q=; b=PPJ/I3N4ClvvyMqa8leDDlMOvwigRTvhkVJPBOgkTHe6ij2679S7Hlgw8Vz2cD/CAT 1+h064TSw3j3UdEXiHpzPXxXWWCb7OG003KoFikaQPwVrrcqfTdnlurF8FvoxTLzm2ob 123gCOdH+60uxXklkr5K5r1FTGWz7i02xUv3BPZJtvoc/zJRmMpsbIAwVhdibnGdn9yJ pu8qN7ISMCoLklPbPApZcVDOteUG3n9yrwoB+xX1U/5oo8drZsQTfRlbDFBh35R4WPUU pg70gbM+ieA4WuUyt0WL+WKC6c8Z4cm0jwnjVpdJ5fT8PbeTq2bt211eIdffLOrrH019 Hpqw== X-Gm-Message-State: APjAAAV2DgMC5MXZBW6ed0VZ9+jzQe4neLUUVKZrZ5EIPgBM5agcbWKp GXK1ERDkaudo5gfoRjMu6KOor1P5 X-Google-Smtp-Source: APXvYqyj9Jppj2pxQT7Z1mQPV9g35I9H0LJ31+64vVyyR4I5A3IkrZ0mmW8ZqRU88tuN3ucQCqYZAA== X-Received: by 2002:aa7:9090:: with SMTP id i16mr7464523pfa.85.1553082526691; Wed, 20 Mar 2019 04:48:46 -0700 (PDT) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id i21sm2600842pfa.14.2019.03.20.04.48.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 04:48:45 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 20 Mar 2019 18:48:42 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 20/20] am: avoid diff_opt_parse() Date: Wed, 20 Mar 2019 18:47:03 +0700 Message-Id: <20190320114703.18659-21-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.548.gd3c7d92dc2 In-Reply-To: <20190320114703.18659-1-pclouds@gmail.com> References: <20190320114703.18659-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 6ce59d0621..b94befd494 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);