From patchwork Sat Feb 16 11:36:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816187 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 47B8417D5 for ; Sat, 16 Feb 2019 11:37:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 386A32C986 for ; Sat, 16 Feb 2019 11:37:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CD292CD46; Sat, 16 Feb 2019 11:37:18 +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 D0B4D2C986 for ; Sat, 16 Feb 2019 11:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727967AbfBPLhQ (ORCPT ); Sat, 16 Feb 2019 06:37:16 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35689 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhQ (ORCPT ); Sat, 16 Feb 2019 06:37:16 -0500 Received: by mail-pg1-f193.google.com with SMTP id s198so6094226pgs.2 for ; Sat, 16 Feb 2019 03:37:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1L6nnZ0CQOEd8nqEx0K4c9mVLDHGNdTtVO2eemjkX9A=; b=XomIp+KVHkWw5TZ0mJBe9oBM/JJZef/Npq9iouge5847d3rjdrz2ISD/H0kOmv7Siv KveVWjeMkhEgYNkimG2sCSpBzbP63Jx5pMrYyMOOqwcR0ajVqd90nXFbfO/tsccAobTo RI5Sly3ANpYyyBmiqQzUHsxe+grmmzphhw/tLMNcevKqCXH0Sk3znMHSk/d2ba1cA19O bb2NKMMTdfmOlWGXcxuv7q8AuU9AmeD9vge5gKDeUiWfeKzi3ebUzXvGC2ABedO6o9ta wmBTmIYFcP2B7v/uX14vtgRWwv/Ya5wMNKjD8ZAeN53Pk+j9QP92Y2C9fpXoZh+W7Smx MPUA== 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=1L6nnZ0CQOEd8nqEx0K4c9mVLDHGNdTtVO2eemjkX9A=; b=Ewb1/rvmrG5cpPpwU6jEEXFzEopcfcF6FuUT+8RutuhKpkfCJ4DG/+mLjQ3Vm4PvxQ TK1Z4duSwJ9ejR14FAvU+EU1RiJbr7VJ7Z94CMeCuZsOcuKRhMwZtL+Al93QzWO/bzQk wVBvct/PuThZTm1HBbFQd152ve53TXMSgfMqdTDEmgNdPEZNXP5jbEmYiyVkkIdpoy9r LAxQni17Tc6bMq56p9VLjG7v6cfRGKnO8ia8jIpHjeBbTYNRtmy72SNbJN2KzzFSivZS 5o+iyyFwf99APYJDPtvM3yHP6raPnjNoHunV+/h36HdAKNxz8DFiBpPSf6czP2wFE0fV C7GQ== X-Gm-Message-State: AHQUAuZLSHxEHUaQ4aZIMUjNK6EaU5vtmAbgzvOXhEwPztwfDIa0k3Bi KcaTGcOkk8EkQXaHkLlOWY0= X-Google-Smtp-Source: AHgI3IaTae7s25NEEzaDc+YvgKLrk5XrFQNcMr4YYAL8ghVQZDvrju3RE2TVnPFXUfu+BDZuHhR21w== X-Received: by 2002:a63:5153:: with SMTP id r19mr9775255pgl.281.1550317035818; Sat, 16 Feb 2019 03:37:15 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id w10sm12717473pge.8.2019.02.16.03.37.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:15 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:11 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 01/21] diff-parseopt: convert --patch-with-raw Date: Sat, 16 Feb 2019 18:36:35 +0700 Message-Id: <20190216113655.25728-2-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index 4bc9df7362..12e333c67f 100644 --- a/diff.c +++ b/diff.c @@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "raw", &options->output_format, N_("generate the diff in raw format"), DIFF_FORMAT_RAW, PARSE_OPT_NONEG), + OPT_BITOP(0, "patch-with-raw", &options->output_format, + N_("synonym for '-p --raw'"), + DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW, + DIFF_FORMAT_NO_OUTPUT), OPT_END() }; @@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--patch-with-raw")) { - enable_patch_output(&options->output_format); - options->output_format |= DIFF_FORMAT_RAW; - } else if (!strcmp(arg, "--numstat")) + if (!strcmp(arg, "--numstat")) options->output_format |= DIFF_FORMAT_NUMSTAT; else if (!strcmp(arg, "--shortstat")) options->output_format |= DIFF_FORMAT_SHORTSTAT; From patchwork Sat Feb 16 11:36:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816189 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 1FFD917D5 for ; Sat, 16 Feb 2019 11:37:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 119402C986 for ; Sat, 16 Feb 2019 11:37:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05F4C2CD46; Sat, 16 Feb 2019 11:37:23 +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 A6A662C986 for ; Sat, 16 Feb 2019 11:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbfBPLhV (ORCPT ); Sat, 16 Feb 2019 06:37:21 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37206 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhV (ORCPT ); Sat, 16 Feb 2019 06:37:21 -0500 Received: by mail-pg1-f196.google.com with SMTP id q206so6091142pgq.4 for ; Sat, 16 Feb 2019 03:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EI6iADq4mEfiqdHjsFNg+D7GzxgJW4c3B/6yv7BN4jg=; b=gTvMTX0UthFCMrpQ0Z93QEbglwDbG0UCAJ/KC2j+Gpepq4ExFA4dNIXndke+dqT1V9 yehlhQRNEjfgPoZxpSaGiLZ3cGjmGiLEL8f+GnqYJ5zNrcqSLRGCU9Q5t2kyDypGufDV aw5xBlv5S4Hu5kIlg+1BHq/a/YCMkvLg28RT2IH4zJdwoOSy9l3JKgNVAnWYG9IjB3g7 ISspZfz8fRI0uLQmeCJ2EpUytxQEWxlrSpGaumVrV/VbY8TIarlJ4/GVWtwh+3G8BzRa 3hcnQmSpA/iE91GYjtx2QeHsA3O5L3msRGZu7GmjtD7txo81xUef3PR0Qhuy1d4yi2g0 bRrA== 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=EI6iADq4mEfiqdHjsFNg+D7GzxgJW4c3B/6yv7BN4jg=; b=gZB+ggv+lEyVV7v4Vx1u7glkDlSaiRnxC1ndw7QoiZ9FaclTKTRVX8cZnNmwfpqEIj t2phLpHps+VqY4EbzTd9WRJUyhJUHmWC5KGzgjay9a5HJdVKRb9hHaQBowkEjH263MWx 17/tfk3VmZA3rrQcY31Ief+5OuSZWRcA6/vVTLDZW0EplYCT7pEuPaFEJyBtRuBx5SQ/ ke6r3lYqZoBvTXEp35fth/b++QlaOSmufMHSRLmZZ0veUh7aJIGW/4bhVkAi6GBSab8D 3qAU7+1D5h9Or6GhCUp2oQiDqQ8eIdQb0lFmB17Kt0y3CO8lD9722j87/vso4l/UPU2n sRjA== X-Gm-Message-State: AHQUAuZTkTHYf9Eel86FnBSv1sJTeAaLK+3c83LHGjdIZ+KXOqX5t18I nx+zb5cWi09Lw5CSAfiXEfA= X-Google-Smtp-Source: AHgI3Ibf1jAILJApJ+Ky/MDgvVYweVS8LnlIItJi21DCut5R4QLqC0b4lDr6tvH5PbdBqNH0KTBQLA== X-Received: by 2002:a63:f141:: with SMTP id o1mr9949705pgk.134.1550317040561; Sat, 16 Feb 2019 03:37:20 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id c23sm9385724pgh.73.2019.02.16.03.37.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:19 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:16 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 02/21] diff-parseopt: convert --numstat and --shortstat Date: Sat, 16 Feb 2019 18:36:36 +0700 Message-Id: <20190216113655.25728-3-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/diff.c b/diff.c index 12e333c67f..419b6ac4ae 100644 --- a/diff.c +++ b/diff.c @@ -4905,6 +4905,12 @@ static void prep_parse_options(struct diff_options *options) N_("synonym for '-p --raw'"), DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW, DIFF_FORMAT_NO_OUTPUT), + OPT_BIT_F(0, "numstat", &options->output_format, + N_("machine friendly --stat"), + DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG), + OPT_BIT_F(0, "shortstat", &options->output_format, + N_("output only the last line of --stat"), + DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG), OPT_END() }; @@ -4933,11 +4939,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--numstat")) - options->output_format |= DIFF_FORMAT_NUMSTAT; - else if (!strcmp(arg, "--shortstat")) - options->output_format |= DIFF_FORMAT_SHORTSTAT; - else if (skip_prefix(arg, "-X", &arg) || + if (skip_prefix(arg, "-X", &arg) || skip_to_optional_arg(arg, "--dirstat", &arg)) return parse_dirstat_opt(options, arg); else if (!strcmp(arg, "--cumulative")) From patchwork Sat Feb 16 11:36:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816191 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 800C7922 for ; Sat, 16 Feb 2019 11:37:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 710E52C986 for ; Sat, 16 Feb 2019 11:37:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62AF52CD46; Sat, 16 Feb 2019 11:37:28 +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 E8EB92C986 for ; Sat, 16 Feb 2019 11:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728113AbfBPLh0 (ORCPT ); Sat, 16 Feb 2019 06:37:26 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39617 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLh0 (ORCPT ); Sat, 16 Feb 2019 06:37:26 -0500 Received: by mail-pg1-f193.google.com with SMTP id r11so6078323pgp.6 for ; Sat, 16 Feb 2019 03:37:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JnyrUaL/kZL6vPDg/HP2kg0btx0wRK4SlqgkVv2Eras=; b=gMWCx2JPEGAFjuDwbqh/ON/XH8JS6N95B7GkH/1gxDHFFSkHG0NFzlVM8INtN8c/VH ZafR8NVcPlvNYY41wpWy90/bNUkrDqm48yYZff32ZGKNVN8SGi+FLKAsyD6n0SJEgBDw SRenpNTvzinBJjM0MXdXPw4XYAwxPYLa0BqnDwWf8oAXHKdFOkOfen2tWHuHECoL1AtR DolFGR2XQWIS8UMG3oj9UwMXrh+uDVTYJ7Bnzdv5fOllWO4DFYwexztovbAa4PtMV6fK x9m8/WttKT93cmbmyMsN65XTr78YIPte54EyCCwNxJF9F+jrI6NY9bFaw4HRPpxM6kNq s57g== 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=JnyrUaL/kZL6vPDg/HP2kg0btx0wRK4SlqgkVv2Eras=; b=Icyx/JrO9cCRWnsf+0lHNOwluKpIFKxKGUy7LVuRYQohZgnhkpqVn1JKrC4s6z633D BhZ82huLtg8JPgpICZOiIvcyrcbzRRJxP9FkZsmjLVGmuwa8iVO4JhLLzN7MOX5Y/t41 Ysz4w06F7TT5V9FDHlRPi+XIMdl67QpX/GyWqhRJFpb49xvNmtY1MB4wys5149Bh1KN6 tci1RmvRINev1pKWcNdWdgeVQtlCa1+6cVi2xEefUYrJNTi9v9Hz7ZEDg/2OHTg3dnV0 aGOMWLfv1kW098/T5b2oDT2FxdaGXrzIh1/3ihU4JshsQ7QH4Ncn3LSoazVTPTrr9h93 9mgQ== X-Gm-Message-State: AHQUAuZCD7g8mEsfVevTd/be3L6ZoP5P1T8ZTHLTfZoCRdHjuWQDbX5I eck9CTh+OASBlK/A1mwpFko= X-Google-Smtp-Source: AHgI3IaGpI0HB2rHOCPrXkDtdw+rEQ/X747cvWS8IcRNEcxk/JrdTEfq8nVfC3LgK8L6bzVyypXkCw== X-Received: by 2002:a62:fb07:: with SMTP id x7mr14361148pfm.71.1550317045777; Sat, 16 Feb 2019 03:37:25 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id f67sm10987278pff.29.2019.02.16.03.37.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:24 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:20 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 03/21] diff-parseopt: convert --dirstat and friends Date: Sat, 16 Feb 2019 18:36:37 +0700 Message-Id: <20190216113655.25728-4-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- Documentation/diff-options.txt | 7 ++++++ diff.c | 39 +++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 0711734b12..058d93ec4f 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=`, number of modified files, as well as number of added and deleted lines. +-X:: --dirstat[=]:: Output the distribution of relative amount of changes for each sub-directory. The behavior of `--dirstat` can be customized by @@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: `--dirstat=files,10,cumulative`. +--cumulative:: + Synonym for --dirstat=cumulative + +--dirstat-by-file[=...]:: + Synonym for --dirstat=files,param1,param2... + --summary:: Output a condensed summary of extended header information such as creations, renames and mode changes. diff --git a/diff.c b/diff.c index 419b6ac4ae..1cdbe8e688 100644 --- a/diff.c +++ b/diff.c @@ -4867,6 +4867,22 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg) return 1; } +static int diff_opt_dirstat(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + if (!strcmp(opt->long_name, "cumulative")) { + if (arg) + BUG("how come --cumulative take a value?"); + arg = "cumulative"; + } else if (!strcmp(opt->long_name, "dirstat-by-file")) + parse_dirstat_opt(options, "files"); + parse_dirstat_opt(options, arg ? arg : ""); + return 0; +} + static int diff_opt_unified(const struct option *opt, const char *arg, int unset) { @@ -4911,6 +4927,18 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "shortstat", &options->output_format, N_("output only the last line of --stat"), DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG), + OPT_CALLBACK_F('X', "dirstat", options, N_("..."), + N_("output the distribution of relative amount of changes for each sub-directory"), + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, + diff_opt_dirstat), + OPT_CALLBACK_F(0, "cumulative", options, NULL, + N_("synonym for --dirstat=cumulative"), + PARSE_OPT_NONEG | PARSE_OPT_NOARG, + diff_opt_dirstat), + OPT_CALLBACK_F(0, "dirstat-by-file", options, N_("..."), + N_("synonym for --dirstat=files,param1,param2..."), + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, + diff_opt_dirstat), OPT_END() }; @@ -4939,16 +4967,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (skip_prefix(arg, "-X", &arg) || - skip_to_optional_arg(arg, "--dirstat", &arg)) - return parse_dirstat_opt(options, arg); - else if (!strcmp(arg, "--cumulative")) - return parse_dirstat_opt(options, "cumulative"); - else if (skip_to_optional_arg(arg, "--dirstat-by-file", &arg)) { - parse_dirstat_opt(options, "files"); - return parse_dirstat_opt(options, arg); - } - else if (!strcmp(arg, "--check")) + if (!strcmp(arg, "--check")) options->output_format |= DIFF_FORMAT_CHECKDIFF; else if (!strcmp(arg, "--summary")) options->output_format |= DIFF_FORMAT_SUMMARY; From patchwork Sat Feb 16 11:36:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816193 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 DC4CF922 for ; Sat, 16 Feb 2019 11:37:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD5872C986 for ; Sat, 16 Feb 2019 11:37:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1C282CD46; Sat, 16 Feb 2019 11:37:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6315B2C986 for ; Sat, 16 Feb 2019 11:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728171AbfBPLhb (ORCPT ); Sat, 16 Feb 2019 06:37:31 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45728 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhb (ORCPT ); Sat, 16 Feb 2019 06:37:31 -0500 Received: by mail-pl1-f195.google.com with SMTP id r14so6280998pls.12 for ; Sat, 16 Feb 2019 03:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w2j+39L0SZuLz7tH9WBUwitNrZeJ9smd07RyrGJd1u8=; b=sAcY+JAjX+/Rx34mkwFFWEThFNpYxZ5Z7q8N2B6vV3s4vo0B8YQgF1jK1VCqq6HBlz xTAoJQKeytMKnKVPXPH3YoW79huXG/3PlmoVEyAqspBsqLreGaxl9Y/rejHN4ZqzU1tL d5KT+vpz/z+pWp4gZG3lvwONOkmnZpScUmx1VPAIzZjkBMc69Ba1IKZFG8PO2lBmLbaE D3FVDobDb+D8+t9upx4RL/ZWSHT6tMJtonjSe3am38lVAdsCQSpZZvCB52eejYOriHFm 7LBRTfQzMTpcsdA+6e2PJSW+m1Wc4iO+/Car0oNdXmWAvqbNPdsE24fOA1mtuKQeub3d iySg== 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=w2j+39L0SZuLz7tH9WBUwitNrZeJ9smd07RyrGJd1u8=; b=SJIsndkoM1TGptBkIKehOyd75jZ1FkIfgN5S/JoFK5ID+phZXlKhJWBvqmfBNV0SM5 r5r5UAKHE0KlwLut8GC6GJgAE98X7trSayDdSzNcEOvBuDKMxawkDB9qkD7Lc9Y7NP9B kFJydZy6enQec9zmJ2dDUE7Q654rDH5uSpXE3Xa7Yc3qQal7HOm6rTcSDEdUWYeq+9Ga 2rq/+SnF9gZYC4GFxQybX7UtUq6z0jpnXqNPpHHqVSScEenC9c3g6x7Jo+XMC41s3S7t d2RHfy083NQaE+00NHI1O0BCtKStMXS87/gSMVdDoDHPmpbslcbqbIpHjjUUC9u4M/eB bexw== X-Gm-Message-State: AHQUAua64LsP7MAM8u8ll0H9HmI2v53LUwVAJ50IJ0zi0CMxVhCWvNn4 VfcfuLwkfDTJfpzTL6v+Fht00Xsj X-Google-Smtp-Source: AHgI3IZXEgbPwcMbhTuFwducSaINR/68h7rVRTqsccqB/poym4taoolIQHwNvYeMSY72PQh+IvKGsA== X-Received: by 2002:a17:902:7006:: with SMTP id y6mr1406354plk.260.1550317050519; Sat, 16 Feb 2019 03:37:30 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id k65sm5398276pge.74.2019.02.16.03.37.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:29 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:26 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 04/21] diff-parseopt: convert --check Date: Sat, 16 Feb 2019 18:36:38 +0700 Message-Id: <20190216113655.25728-5-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/diff.c b/diff.c index 1cdbe8e688..5e16082091 100644 --- a/diff.c +++ b/diff.c @@ -4939,6 +4939,9 @@ static void prep_parse_options(struct diff_options *options) N_("synonym for --dirstat=files,param1,param2..."), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_dirstat), + OPT_BIT_F(0, "check", &options->output_format, + N_("warn if changes introduce conflict markers or whitespace errors"), + DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG), OPT_END() }; @@ -4967,9 +4970,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--check")) - options->output_format |= DIFF_FORMAT_CHECKDIFF; - else if (!strcmp(arg, "--summary")) + if (!strcmp(arg, "--summary")) options->output_format |= DIFF_FORMAT_SUMMARY; else if (!strcmp(arg, "--patch-with-stat")) { enable_patch_output(&options->output_format); From patchwork Sat Feb 16 11:36:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816195 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 C44F417D5 for ; Sat, 16 Feb 2019 11:37:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B56B82C986 for ; Sat, 16 Feb 2019 11:37:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A94F42CD46; Sat, 16 Feb 2019 11:37:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5831D2C986 for ; Sat, 16 Feb 2019 11:37:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbfBPLhg (ORCPT ); Sat, 16 Feb 2019 06:37:36 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45036 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhg (ORCPT ); Sat, 16 Feb 2019 06:37:36 -0500 Received: by mail-pf1-f194.google.com with SMTP id u6so6123682pfh.11 for ; Sat, 16 Feb 2019 03:37:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=504YtP9c1Vs48gl3br293hIlq3E4PGdQAmXfEyWhldU=; b=TZHiidAVOtL3NIDTcqHzSWmqrFo9TH2AM53N6VE57xSuYzXUYKmgV3P9CgyZ2RooZu x67gew0JZWDl2jBKbZOgoP2iHpF0JsGsQnD8wMkLaD+RVk3OFtrN0EMoUc0x/Jea04J9 pAxInUTfIDxnWHDBJ6VqjMf3bOckcoLeBE0bCj2eBIcRLs7D8ghFR9ox6mEvJHJjp/DF x9Jwa0lmyvemBgXJBHOmqoDfaxUmstTrnviu8+WCKykX2j/E64SiloOKSr77PrZ43mEo z2d4D/2o76KjogGY8YFUa1rfLk1JRRZ/KUtStHPP7QJ5cNlNdSmphFhOdts/yS7F3sA+ IEkQ== 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=504YtP9c1Vs48gl3br293hIlq3E4PGdQAmXfEyWhldU=; b=j9RhOh0ovm4QwDbHiyglvz0WL7FjvIXMGSIlfYjVe0/l9QVfDeh2L9X889fOKGZUeA lgW0pi9vUZKXEhg+rGLF01wT/HgP7qmlVMwo/hLdGSvb42EWs7naeQRhE7vRESbFSlSC TcH1+SJD58bJYvFvl6kOiyUxDtppeVOTbtZZ+n9JBfO6A1RWho157HEs+GAXisgfu5cs t/5RHclbo3jgptQAY8ucq3a37OBDGVahDJnzoUUeJWLNX2Sj2Tm3QeomINA3yWJLKwPh vv8re0IR+Bz1JkmUiq5rDtoxyJM/bPvobDK3E1E6YkvDhl2QdjcHcuBk0PgyIulF259J qs5A== X-Gm-Message-State: AHQUAuaFGY8aJTKru48lHDfZfMh2nfpIwn1PGmrlOrGvT4P6ZsNA7z/g End34+4Ey3ChBg4neGTPID0= X-Google-Smtp-Source: AHgI3IaK4ryKrDyqvZ44JOw8Lbm9frToWOT/D8zXbBwrPbpADilFCISZoorpv/++wUaFbLh3m8wCjQ== X-Received: by 2002:a63:d5f:: with SMTP id 31mr9742578pgn.274.1550317055198; Sat, 16 Feb 2019 03:37:35 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id s71sm18138235pfa.122.2019.02.16.03.37.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:34 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:30 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 05/21] diff-parseopt: convert --summary Date: Sat, 16 Feb 2019 18:36:39 +0700 Message-Id: <20190216113655.25728-6-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/diff.c b/diff.c index 5e16082091..0276f25200 100644 --- a/diff.c +++ b/diff.c @@ -4942,6 +4942,9 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "check", &options->output_format, N_("warn if changes introduce conflict markers or whitespace errors"), DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG), + OPT_BIT_F(0, "summary", &options->output_format, + N_("condensed summary such as creations, renames and mode changes"), + DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG), OPT_END() }; @@ -4970,9 +4973,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--summary")) - options->output_format |= DIFF_FORMAT_SUMMARY; - else if (!strcmp(arg, "--patch-with-stat")) { + if (!strcmp(arg, "--patch-with-stat")) { enable_patch_output(&options->output_format); options->output_format |= DIFF_FORMAT_DIFFSTAT; } else if (!strcmp(arg, "--name-only")) From patchwork Sat Feb 16 11:36:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816197 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 B01BA17D5 for ; Sat, 16 Feb 2019 11:37:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A142F2C986 for ; Sat, 16 Feb 2019 11:37:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95F352CD46; Sat, 16 Feb 2019 11:37:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35F282C986 for ; Sat, 16 Feb 2019 11:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728269AbfBPLhl (ORCPT ); Sat, 16 Feb 2019 06:37:41 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46118 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhk (ORCPT ); Sat, 16 Feb 2019 06:37:40 -0500 Received: by mail-pg1-f194.google.com with SMTP id w7so6065365pgp.13 for ; Sat, 16 Feb 2019 03:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mx3YU67jcYE6ZV/aAOaTSKW9TuP6stK+x1JgVNbadUU=; b=QViyXfcS9ph+anGAgvTMHNs8H83oxUGwNWWEMpGpfA/M8fWvEgXb0WAT0bFWFJUQjO A3MCoaOO6qg13CTEo3Zwz1SOYppOmdKm0vMaNTaYNbjaKt9Z7nl1p3i7VuvKNksfWknY JArRkEDWHxEUahuz0vcS31xcBWWuMtj33O9g2johe2aKGOuLCUf4S8qMVBvHR1pYK2Zl P22KGEdtxFvWqW44K5F1luc9ismpIaJo/Nub5n9+meBIPcvaNu8oJWAE+UGGluVjACES aoZsPLpBUFHDVIZfuJU4Xl0ly97g9aZI6QCQrEnYZ1tcA5S+jE+v9cqUGG7Q65+YS0HA dokQ== 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=mx3YU67jcYE6ZV/aAOaTSKW9TuP6stK+x1JgVNbadUU=; b=h1hhK9F7mh8Q3ZUm/J6Xar1Tue7o1dl9/A9lJqPmeFSt/XIiaiwgFRWeVa/KA5wFB1 zluuQAAAoL1m9RcsE4JQiDLk+HIq4TwbGNOMeVR/9eTQdRwuo72BmrILrpQGugvMBEJW TDeql5pFkK4Keq+xrh/TybH1gJQTkXdSHePFHS8rANMCtEVRPbnEQ+Im+lznmye3xEOJ 82Wmr9w0XcoJhkyGb6agQSz+vuX9LZ112xwjrSt20vAqqTSTKn096/ojU/4jP3sOUuQp K6ZwtxfSFgsv12upadqlE5Hqdaxs6DS9YWZf9d7LoCTstvhhSXNT79u4m7JzaRGrLfvy hnaQ== X-Gm-Message-State: AHQUAubPbNhM1UYR0MseUonC7WbnmNgXLuwKJjVsGwoaPuiqQa/y7Oqg WaTr6AaT+8wz0EVcvU01D7s= X-Google-Smtp-Source: AHgI3IbfPe3WzhQjUaQncmAkxtA/DmoUcdniGptFWGpfa5NEMAis3ezDDaKakHDNc+2mASmZ0sOeDw== X-Received: by 2002:a63:4005:: with SMTP id n5mr9507173pga.86.1550317059818; Sat, 16 Feb 2019 03:37:39 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id d16sm9424314pgj.21.2019.02.16.03.37.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:39 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:35 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 06/21] diff-parseopt: convert --patch-with-stat Date: Sat, 16 Feb 2019 18:36:40 +0700 Message-Id: <20190216113655.25728-7-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index 0276f25200..b9811aefef 100644 --- a/diff.c +++ b/diff.c @@ -4921,6 +4921,10 @@ static void prep_parse_options(struct diff_options *options) N_("synonym for '-p --raw'"), DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW, DIFF_FORMAT_NO_OUTPUT), + OPT_BITOP(0, "patch-with-stat", &options->output_format, + N_("synonym for '-p --stat'"), + DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT, + DIFF_FORMAT_NO_OUTPUT), OPT_BIT_F(0, "numstat", &options->output_format, N_("machine friendly --stat"), DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG), @@ -4973,10 +4977,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--patch-with-stat")) { - enable_patch_output(&options->output_format); - options->output_format |= DIFF_FORMAT_DIFFSTAT; - } else if (!strcmp(arg, "--name-only")) + if (!strcmp(arg, "--name-only")) options->output_format |= DIFF_FORMAT_NAME; else if (!strcmp(arg, "--name-status")) options->output_format |= DIFF_FORMAT_NAME_STATUS; From patchwork Sat Feb 16 11:36:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816199 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 0E1E5922 for ; Sat, 16 Feb 2019 11:37:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1F5C2C986 for ; Sat, 16 Feb 2019 11:37:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E681C2CD46; Sat, 16 Feb 2019 11:37:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87A952C986 for ; Sat, 16 Feb 2019 11:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728304AbfBPLhp (ORCPT ); Sat, 16 Feb 2019 06:37:45 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36115 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhp (ORCPT ); Sat, 16 Feb 2019 06:37:45 -0500 Received: by mail-pg1-f194.google.com with SMTP id r124so6089688pgr.3 for ; Sat, 16 Feb 2019 03:37:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R7hVXdNFGsVdkpaFkisKK5nLKKpIGH0TOjyXb5UstIY=; b=UEgUuPeQQ3f+Mqai8ACfRRsPLv1RkA0ecltkyqxtFTkuUiAISXE+VKp+1i7nkFSCHh uEx1sM2epFwt8Glo/NBrFByWFgBNNWE5ZpPVxA/PsmlApmIoSdM+TO+i0i+BP3N+8OOj feJQ2nlSncneqelASTkuxOq8TfKqm3HdChS1dCeBiizS3QW3PtssIY+atL6szLjz4WhU bjDG8/MYMfjVk5cx85R5afDcPzrPfRRW+KrveoQ/ILvMdj1WmuqwdMhrRkuDvXht0RKh p8VA1V4HQ+zr41QSE2DflM1jCeGjrlbm6XJUwJH9kMZTraa09FKKYBP4PsWHpw9xQrl7 CPCQ== 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=R7hVXdNFGsVdkpaFkisKK5nLKKpIGH0TOjyXb5UstIY=; b=OKFHrWNWzD6XPN4+sVeU46A7exiTH/RBQkTQotcZpJMyZ4QkIwImnwOhoF1Hfsiycq 3CEbcPBH72uV+X/4jxOAe2Xs2SFVo9rTIXBPn3a2MHMDU/Y5FrmDF7G2yfgyKCWkFE7W /8aPpJ7Te8TAaXoxdNDslzwDSogtOXqwoiqbCsBCzLsOXqef86o/rzR8lEyJ5LXtwn0N RI7BWrSdSemg7NcNVO4se6QOXlcGhXLSZFEDCuHcmC7Y6G/bPPd8mAhZ701mFFU+ZbSc dkJ9EfcmTbNe9QlYyxuOA2JRNSKolxsxDFuZJDG2OLfMLQCE0vmNjNyID22xFO9FYLEN EtrQ== X-Gm-Message-State: AHQUAubc3OGjtP/ZzHT3MITjAaggz2PYU3LTtpL1NHbBSMmX39wPZDpR toLRGC+hY/HjNRgG7nVNYPY= X-Google-Smtp-Source: AHgI3Ib5mu133T2yQNRtYmQavqtvmGJBS+WCXMzmG6hEL3MbnYNHF3As9ut9n8takz4U25fiJu34eQ== X-Received: by 2002:a62:4b4d:: with SMTP id y74mr14305933pfa.186.1550317064535; Sat, 16 Feb 2019 03:37:44 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id n186sm10485222pfn.137.2019.02.16.03.37.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:43 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:40 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 07/21] diff-parseopt: convert --name-only Date: Sat, 16 Feb 2019 18:36:41 +0700 Message-Id: <20190216113655.25728-8-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/diff.c b/diff.c index b9811aefef..7ea308814f 100644 --- a/diff.c +++ b/diff.c @@ -4949,6 +4949,9 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "summary", &options->output_format, N_("condensed summary such as creations, renames and mode changes"), DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG), + OPT_BIT_F(0, "name-only", &options->output_format, + N_("show only names of changed files"), + DIFF_FORMAT_NAME, PARSE_OPT_NONEG), OPT_END() }; @@ -4977,9 +4980,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--name-only")) - options->output_format |= DIFF_FORMAT_NAME; - else if (!strcmp(arg, "--name-status")) + if (!strcmp(arg, "--name-status")) options->output_format |= DIFF_FORMAT_NAME_STATUS; else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch")) options->output_format |= DIFF_FORMAT_NO_OUTPUT; From patchwork Sat Feb 16 11:36:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816201 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 CC4FF17D5 for ; Sat, 16 Feb 2019 11:37:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC8202C986 for ; Sat, 16 Feb 2019 11:37:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0CF32CD46; Sat, 16 Feb 2019 11:37:51 +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 59E6B2C986 for ; Sat, 16 Feb 2019 11:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728348AbfBPLhu (ORCPT ); Sat, 16 Feb 2019 06:37:50 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33514 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhu (ORCPT ); Sat, 16 Feb 2019 06:37:50 -0500 Received: by mail-pf1-f195.google.com with SMTP id c123so6152163pfb.0 for ; Sat, 16 Feb 2019 03:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l0Ct8Z714Siw8wBJ1GBy9Ich8auweyrQ4QOOxtOuyeQ=; b=IiBWlh5An1NZ64yirJA6GIfcxjybObzHgSaQLowCW5yowRVTJnHEii2HA/TWgeAC7T b2LY3Qd9PQ15BkztVhROz4s1eXK/HpAMT6x3gAYiOxq9Wzv7DH4kJ9mdLJqmt6zjiv7d gG+6t9JW81BGe7zqdOEpyni9rIyNB/nEjxovBoMNR+SI5QdaqtOjlV/J3qM4+wkIwTX4 IQbWQz+OpakqBiayfzQmPgbYW275AntT0yItzQQ7X6QLiAhCYH/90Lzmc1QeQzPVb7Vm rMEvgoleQzVItVZ+oTPzpYvc7JcmLHhgVX1peJt9PotW8ZyL2FaHLQWFZjsYO9Br+A5r 4/+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=l0Ct8Z714Siw8wBJ1GBy9Ich8auweyrQ4QOOxtOuyeQ=; b=kB2W3nWovlYa2q9VepTdcZdIQhSBNdEkn1c1+pumdtXXNnsGydzTaWrQ9jbg3iMhgO kwTU4R41ADAu3oO7bicP3P6ztwjAHtmStzyRPkB8UodrumcgFYkZ8crgwbVeInnms879 FsF5YPLw/arOxkpf87jSp0I9a3XZDwPytnxyL8Q167Pal5TK4h2wANwWQbldsyjBEUbR 9tfVR1QLzFrqOwA8ef8eQzUYvF+EpxMVoD/pePs83fYpHz+E1P/sXl6xsdJoX5TRtMl9 w2R+8mJ68s/ZDYcGO6aJa05QRgeBDN43Zaz03vcyklKxGfgKT4AEw12dGWI8r6AlCIeY Tr0g== X-Gm-Message-State: AHQUAuZj/hT41Dmhio2BGXebmkSa/9MJ2pnY9U+QxHlYnd3R9iU5WUNA DDZpHQHbB5C5DKSW63KNSns= X-Google-Smtp-Source: AHgI3IbujMBK5yLGvt+DBXd/Mk7jrsP2H41FHAdxqK7T4rVUTlVoCuRN+lluJzZ+nPOpBeQM/gtUfw== X-Received: by 2002:a63:cc12:: with SMTP id x18mr9708731pgf.33.1550317069245; Sat, 16 Feb 2019 03:37:49 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id a12sm8312900pgt.58.2019.02.16.03.37.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:48 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:44 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 08/21] diff-parseopt: convert --name-status Date: Sat, 16 Feb 2019 18:36:42 +0700 Message-Id: <20190216113655.25728-9-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/diff.c b/diff.c index 7ea308814f..99047fb5fe 100644 --- a/diff.c +++ b/diff.c @@ -4952,6 +4952,9 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "name-only", &options->output_format, N_("show only names of changed files"), DIFF_FORMAT_NAME, PARSE_OPT_NONEG), + OPT_BIT_F(0, "name-status", &options->output_format, + N_("show only names and status of changed files"), + DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG), OPT_END() }; @@ -4980,9 +4983,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--name-status")) - options->output_format |= DIFF_FORMAT_NAME_STATUS; - else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch")) + if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch")) options->output_format |= DIFF_FORMAT_NO_OUTPUT; else if (starts_with(arg, "--stat")) /* --stat, --stat-width, --stat-name-width, or --stat-count */ From patchwork Sat Feb 16 11:36:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10816203 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 A967917D5 for ; Sat, 16 Feb 2019 11:37:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 991622C986 for ; Sat, 16 Feb 2019 11:37:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DAF92CD46; Sat, 16 Feb 2019 11:37:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37BBF2C986 for ; Sat, 16 Feb 2019 11:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbfBPLhz (ORCPT ); Sat, 16 Feb 2019 06:37:55 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45310 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLhy (ORCPT ); Sat, 16 Feb 2019 06:37:54 -0500 Received: by mail-pg1-f193.google.com with SMTP id y4so6072849pgc.12 for ; Sat, 16 Feb 2019 03:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s7MY/XfIX529YSTHE32PpcTM6WI44743a28+xdW9DAI=; b=uLexcmvtfFfCgM+AsgGOfHFUpL42Lvpp0X/N0o3kUQz22t/Ki0Rdwrkq3Q2MWIfJGA GNDrBiPROx0pzXUjrFq1hDp5ZNXkPjzd6kzBfW4dxGMZzWzsuI5Kyjr/98LXzL3BlHdd ECsL7x9J5IDCh9K7lrCdt47j8eLrnDvnzHMIYwVLpkFPj2cXvGFay7VFy3MA3gW3L7Qj Dv3fmWSGE9Bgxz7RTYOlafubKolnudi4vjSm33CvAsbwf+1ug3QwUJzeOMjCei+iCp+Y T1Fi7OWSwibBb4NOWo6yc/b5bQll6Cl7iCUebXP7X68KTE46PBEu+vZnMtwNNb7Qe/Zs VJXg== 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=s7MY/XfIX529YSTHE32PpcTM6WI44743a28+xdW9DAI=; b=ksdP3BgyV8DkaZuNbDNP8OqYsYNP8m6ixcmT860VDKjRXOkgqFWJ9PrbRmH6J2AtXy iNJUO3s/1nxgKgAY/S2Jh2kyygVTYU7Y7+HE/LBab6QMKb9v+aTuXLGLxDcTGCA+pFo9 FGzwgi0kQfOUS1K+V4t0mFMzqBUc/dd/TSxTzEau8UzmxGCKhLwo0X8OE2HN3JKmuPXv ECOp79Zl6afJ0tsHp/SCzbnRFkeKghvJ4ZOu7gJHNgrHgYO6LmQgaqZuyjr6Ixj0Sy8T xxbKSrDThZ7IYLccpsJ+R7Eb6WM5kCrUdfI5riI0hK5lphsf1m77wRrvfueF5sU92yQx kpiQ== X-Gm-Message-State: AHQUAuYJhkLDMReCKSlxTi0z1wg1vF037NYKxsIVL+KCxonpV/Ppk2c8 r9XZ5XA2PhIktyYAfAym1vdUc4HA X-Google-Smtp-Source: AHgI3IZiiEuKs9/riC2Pou+rBk8Eh4zs9hUWUu9RlsbcPh4SahEucUgYW9vkmB3ChOGTRnNie5g8dA== X-Received: by 2002:a62:5a81:: with SMTP id o123mr14190740pfb.109.1550317073910; Sat, 16 Feb 2019 03:37:53 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id f62sm15000411pgc.67.2019.02.16.03.37.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:53 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:49 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 09/21] diff-parseopt: convert -s|--no-patch Date: Sat, 16 Feb 2019 18:36:43 +0700 Message-Id: <20190216113655.25728-10-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/diff.c b/diff.c index 99047fb5fe..9c8f5336bc 100644 --- a/diff.c +++ b/diff.c @@ -4906,6 +4906,9 @@ static void prep_parse_options(struct diff_options *options) OPT_BITOP('p', "patch", &options->output_format, N_("generate patch"), DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT), + OPT_BIT_F('s', "no-patch", &options->output_format, + N_("suppress diff output"), + DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG), OPT_BITOP('u', NULL, &options->output_format, N_("generate patch"), DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT), @@ -4983,9 +4986,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch")) - options->output_format |= DIFF_FORMAT_NO_OUTPUT; - else if (starts_with(arg, "--stat")) + if (starts_with(arg, "--stat")) /* --stat, --stat-width, --stat-name-width, or --stat-count */ return stat_opt(options, av); else if (!strcmp(arg, "--compact-summary")) { From patchwork Sat Feb 16 11:36: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: 10816205 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 D8902922 for ; Sat, 16 Feb 2019 11:38:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C31DD2C986 for ; Sat, 16 Feb 2019 11:38:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B15152CD46; Sat, 16 Feb 2019 11:38:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01F5C2C986 for ; Sat, 16 Feb 2019 11:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728414AbfBPLiA (ORCPT ); Sat, 16 Feb 2019 06:38:00 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42829 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLh7 (ORCPT ); Sat, 16 Feb 2019 06:37:59 -0500 Received: by mail-pf1-f194.google.com with SMTP id n74so6134330pfi.9 for ; Sat, 16 Feb 2019 03:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iElUrep7z12wfcIkIJmiyTke6EkIPaAau9utHn7cCS4=; b=uMODgbnxa0IXg6cEYUgAcxFlJtQfv0wlfdOxvMxz5Bh6kIPBrH+z6z4/3UqZFzzwWp rbS43cX9exGRs7tQ87xX/3yREPh/QEmKWYG/PIZc3arppCyfBZ+zwgJvHDR4f7/4RErC Dne2s8I92JbLeCZjM4W76NVu0u+x7uGjU4wvbmXFBdtDboAlQOcX3lAuAGClcnhRu6l0 gQli4gIdEy1/Tskybc6jNsDBaxjiWHRExlhl+9GZjHxvOvfy9VYEmSUHQ08N4rA7G7BX 3Gk84wZYo+ajfCQdBNwntyo58mhHC8jazVbjF91+5o4/CzNRruz0issBmWOIT3pE+w3F uvwA== 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=iElUrep7z12wfcIkIJmiyTke6EkIPaAau9utHn7cCS4=; b=oD6/Al53K/WspYGf07+q1s5QBc9AvPfBZ+aGp7tMY96JUBRMFqpOCUJSkAWRGm4POk x5jIhdaw+9H3Y9SIXxmu03zAwtK7TvegUZmKv4RtxJjhjiBa96zHrSQzzhK6FBpQL6h5 PWhD2pBHefGglPI212bINVmq3JKnkla8SP9PbmvpK48ZZSKcES4KMj48ozJqOlKcFKWH bUIGzvT595tAq18Bywxmk6/Ru75SiLKY8wpHWzqaHd4+B5wfEE52LsP4X4Ay3s3rPCK5 pn7fEa82iOzojuS/4UdnznDZ7cFGDDjvQpuI5goXTMEIjPb+OSrbO8q97KFuT8AkiC/U /fJg== X-Gm-Message-State: AHQUAuZBjqu8rdqf3Ab7mvOUsKNUv8bktbVhE6KgwC4NhVlaQq3Oe5ox ebgrWVi9s1qPDogo+9mErqQ= X-Google-Smtp-Source: AHgI3Ibx+3vIjBUfrdL6yKXuKG0IniosxfywY/Uj7KRncHxLmhzxqxNNYv3ATzvgiZb+dSZoBh1YBQ== X-Received: by 2002:a63:4658:: with SMTP id v24mr13547597pgk.114.1550317078593; Sat, 16 Feb 2019 03:37:58 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id i2sm10051154pgl.53.2019.02.16.03.37.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:37:57 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:54 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 10/21] diff-parseopt: convert --stat* Date: Sat, 16 Feb 2019 18:36:44 +0700 Message-Id: <20190216113655.25728-11-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 118 +++++++++++++++++++++++++-------------------------------- 1 file changed, 52 insertions(+), 66 deletions(-) diff --git a/diff.c b/diff.c index 9c8f5336bc..1feb13deb3 100644 --- a/diff.c +++ b/diff.c @@ -104,11 +104,6 @@ static const char *color_diff_slots[] = { [DIFF_FILE_NEW_BOLD] = "newBold", }; -static NORETURN void die_want_option(const char *option_name) -{ - die(_("option '%s' requires a value"), option_name); -} - define_list_config_array_extra(color_diff_slots, {"plain"}); static int parse_diff_color_slot(const char *var) @@ -4661,77 +4656,56 @@ int parse_long_opt(const char *opt, const char **argv, return 2; } -static int stat_opt(struct diff_options *options, const char **av) +static int diff_opt_stat(const struct option *opt, const char *value, int unset) { - const char *arg = av[0]; - char *end; + struct diff_options *options = opt->value; int width = options->stat_width; int name_width = options->stat_name_width; int graph_width = options->stat_graph_width; int count = options->stat_count; - int argcount = 1; + char *end; - if (!skip_prefix(arg, "--stat", &arg)) - BUG("stat option does not begin with --stat: %s", arg); - end = (char *)arg; + BUG_ON_OPT_NEG(unset); - switch (*arg) { - case '-': - if (skip_prefix(arg, "-width", &arg)) { - if (*arg == '=') - width = strtoul(arg + 1, &end, 10); - else if (!*arg && !av[1]) - die_want_option("--stat-width"); - else if (!*arg) { - width = strtoul(av[1], &end, 10); - argcount = 2; - } - } else if (skip_prefix(arg, "-name-width", &arg)) { - if (*arg == '=') - name_width = strtoul(arg + 1, &end, 10); - else if (!*arg && !av[1]) - die_want_option("--stat-name-width"); - else if (!*arg) { - name_width = strtoul(av[1], &end, 10); - argcount = 2; - } - } else if (skip_prefix(arg, "-graph-width", &arg)) { - if (*arg == '=') - graph_width = strtoul(arg + 1, &end, 10); - else if (!*arg && !av[1]) - die_want_option("--stat-graph-width"); - else if (!*arg) { - graph_width = strtoul(av[1], &end, 10); - argcount = 2; - } - } else if (skip_prefix(arg, "-count", &arg)) { - if (*arg == '=') - count = strtoul(arg + 1, &end, 10); - else if (!*arg && !av[1]) - die_want_option("--stat-count"); - else if (!*arg) { - count = strtoul(av[1], &end, 10); - argcount = 2; - } + if (!strcmp(opt->long_name, "stat")) { + if (value) { + width = strtoul(value, &end, 10); + if (*end == ',') + name_width = strtoul(end+1, &end, 10); + if (*end == ',') + count = strtoul(end+1, &end, 10); + if (*end) + return error(_("invalid --stat value: %s"), value); } - break; - case '=': - width = strtoul(arg+1, &end, 10); - if (*end == ',') - name_width = strtoul(end+1, &end, 10); - if (*end == ',') - count = strtoul(end+1, &end, 10); - } + } else if (!strcmp(opt->long_name, "stat-width")) { + width = strtoul(value, &end, 10); + if (*end) + return error(_("%s expects a numerical value"), + opt->long_name); + } else if (!strcmp(opt->long_name, "stat-name-width")) { + name_width = strtoul(value, &end, 10); + if (*end) + return error(_("%s expects a numerical value"), + opt->long_name); + } else if (!strcmp(opt->long_name, "stat-graph-width")) { + graph_width = strtoul(value, &end, 10); + if (*end) + return error(_("%s expects a numerical value"), + opt->long_name); + } else if (!strcmp(opt->long_name, "stat-count")) { + count = strtoul(value, &end, 10); + if (*end) + return error(_("%s expects a numerical value"), + opt->long_name); + } else + BUG("%s should not get here", opt->long_name); - /* Important! This checks all the error cases! */ - if (*end) - return 0; options->output_format |= DIFF_FORMAT_DIFFSTAT; options->stat_name_width = name_width; options->stat_graph_width = graph_width; options->stat_width = width; options->stat_count = count; - return argcount; + return 0; } static int parse_dirstat_opt(struct diff_options *options, const char *params) @@ -4958,6 +4932,21 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "name-status", &options->output_format, N_("show only names and status of changed files"), DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG), + OPT_CALLBACK_F(0, "stat", options, N_("[,[,]]"), + N_("generate diffstat"), + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_stat), + OPT_CALLBACK_F(0, "stat-width", options, N_(""), + N_("generate diffstat with a given width"), + PARSE_OPT_NONEG, diff_opt_stat), + OPT_CALLBACK_F(0, "stat-name-width", options, N_(""), + N_("generate diffstat with a given name width"), + PARSE_OPT_NONEG, diff_opt_stat), + OPT_CALLBACK_F(0, "stat-graph-width", options, N_(""), + N_("generate diffstat with a given graph width"), + PARSE_OPT_NONEG, diff_opt_stat), + OPT_CALLBACK_F(0, "stat-count", options, N_(""), + N_("generate diffstat with limited lines"), + PARSE_OPT_NONEG, diff_opt_stat), OPT_END() }; @@ -4986,10 +4975,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (starts_with(arg, "--stat")) - /* --stat, --stat-width, --stat-name-width, or --stat-count */ - return stat_opt(options, av); - else if (!strcmp(arg, "--compact-summary")) { + if (!strcmp(arg, "--compact-summary")) { options->flags.stat_with_summary = 1; options->output_format |= DIFF_FORMAT_DIFFSTAT; } else if (!strcmp(arg, "--no-compact-summary")) From patchwork Sat Feb 16 11:36: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: 10816207 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 1D68A922 for ; Sat, 16 Feb 2019 11:38:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D36D2C986 for ; Sat, 16 Feb 2019 11:38:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 008E62CD46; Sat, 16 Feb 2019 11:38:05 +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 99BFC2C986 for ; Sat, 16 Feb 2019 11:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728431AbfBPLiE (ORCPT ); Sat, 16 Feb 2019 06:38:04 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43792 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLiE (ORCPT ); Sat, 16 Feb 2019 06:38:04 -0500 Received: by mail-pf1-f194.google.com with SMTP id q17so6129011pfh.10 for ; Sat, 16 Feb 2019 03:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3e4cwydYt1lq5ZVrvWigeNyRUPk2cI7POqoy22Zq/Tw=; b=F7oDrAvhGGta7W7kD37o0OCwIBbypDm4/EfsgShUGTXKDw5Zj+KXAP655oUHJtJbin C8xAXc8qjCMcMl7PXzytErAUZ8eu8W5xuQuWLY/iKbI8HwJF+iUhk8xuINoVS80SfGFZ CDg0iU/wsT4ZRfNIKUPDLjjjM3pwK1c3Gm0hwJNgCI5jlK59aZRqoTMoyaiw9n+Eet4d sZ0yruxGYiP4fnniPBZCObjaArvzkQHI5Kk4c9kavUuyRj5RUhPYuC2W54Raisrn3A+g xknQEQkwy+vQFzkF1ABr7r9C0p4Ykl0b0k5R740GPPytaPSSNorPJyvMAO8Bf6mKwNW3 uGPA== 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=3e4cwydYt1lq5ZVrvWigeNyRUPk2cI7POqoy22Zq/Tw=; b=SlJJE20sdDZg6MdW+nnbi3YrS1E/5KwgIcl5qpk6e2BdDk53rzfNVBgKxJ6rLFlWvi vh0xLxYN+ucyE4u9ZEiy/i5cPTpUrYPRyc1EPqZkN05R/UjbOzaXE4/w8U3rCVs5jYYq 85ckyCpo5ULQEMx2JGq0LrSmYdSsP5SDgvhviV1huB32l9BBsfxgOnpKBKBXYH8vw1wc ltd3WAC+TTUPE3jqhlTV88gUk66EWMJ8OJq9LjBvdBCeRVfjH0yuuMkjEvReUlu9XBby YTnVXVKwykJZhf5Pz9xJvIH4ZivnWyDad0FVpTgiOYoklQ3D2GNM94eLfNO7gfhv0mHj Qn9g== X-Gm-Message-State: AHQUAubGWVvA3nYN4lkFvTyzM0RzxQVUPSs1gV/UgxbdX+zWwUzLJe2p DVCgL7xkYIQXsqatFirJCjVlgNPy X-Google-Smtp-Source: AHgI3IZ9Outkw51l54YiNoT9NDXku5JIq2Vsipz77Ru8UaJKIE0OFe7RXJargbR8yFsn1kywxgHOyA== X-Received: by 2002:a63:6bc1:: with SMTP id g184mr9967882pgc.25.1550317083385; Sat, 16 Feb 2019 03:38:03 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id k9sm8712403pgo.1.2019.02.16.03.38.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:02 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:37:58 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 11/21] diff-parseopt: convert --[no-]compact-summary Date: Sat, 16 Feb 2019 18:36:45 +0700 Message-Id: <20190216113655.25728-12-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/diff.c b/diff.c index 1feb13deb3..b24f6825a1 100644 --- a/diff.c +++ b/diff.c @@ -4841,6 +4841,21 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg) return 1; } +static int diff_opt_compact_summary(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_ARG(arg); + if (unset) { + options->flags.stat_with_summary = 0; + } else { + options->flags.stat_with_summary = 1; + options->output_format |= DIFF_FORMAT_DIFFSTAT; + } + return 0; +} + static int diff_opt_dirstat(const struct option *opt, const char *arg, int unset) { @@ -4947,6 +4962,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "stat-count", options, N_(""), N_("generate diffstat with limited lines"), PARSE_OPT_NONEG, diff_opt_stat), + OPT_CALLBACK_F(0, "compact-summary", options, NULL, + N_("generate compact summary in diffstat"), + PARSE_OPT_NOARG, diff_opt_compact_summary), OPT_END() }; @@ -4975,12 +4993,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* Output format options */ - if (!strcmp(arg, "--compact-summary")) { - options->flags.stat_with_summary = 1; - options->output_format |= DIFF_FORMAT_DIFFSTAT; - } else if (!strcmp(arg, "--no-compact-summary")) - options->flags.stat_with_summary = 0; - else if (skip_prefix(arg, "--output-indicator-new=", &arg)) + if (skip_prefix(arg, "--output-indicator-new=", &arg)) options->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0]; else if (skip_prefix(arg, "--output-indicator-old=", &arg)) options->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0]; From patchwork Sat Feb 16 11:36: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: 10816209 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 D32A817D5 for ; Sat, 16 Feb 2019 11:38:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C16002C986 for ; Sat, 16 Feb 2019 11:38:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5E542CD46; Sat, 16 Feb 2019 11:38:10 +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 3BC462C986 for ; Sat, 16 Feb 2019 11:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728469AbfBPLiJ (ORCPT ); Sat, 16 Feb 2019 06:38:09 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36305 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLiI (ORCPT ); Sat, 16 Feb 2019 06:38:08 -0500 Received: by mail-pf1-f195.google.com with SMTP id n22so6145567pfa.3 for ; Sat, 16 Feb 2019 03:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OcsJNr7GGb9bAr8Y1C3w0n/ETC4xvGHTUHLJr+HIDlg=; b=EK/Dmx9cHQ5NjAa1adT6BlMu+iza7/krEEC0Uz20F46icqP3O4wKdoynI4HPCGrI04 9POv323g4Q80clGJhmQ9NJArvSf+mBEfj+yYm5NyzPJa7D8mDxSko/64wiLRlas986WJ 3GpwfPlKYGXKLoKoFvzr944j9JqdwD9vVwJ9LJlaqqmRfaatsZaaxfWRGF5NkmWi9zkI XqppOJf+3296cyKGXTXI4Wd4XCpO5iOKBNy3hfdz4ofv5aS9ws2OYNSNg+oHg96OrtcK CbwP/dMPUx2NqwyFlL+OGRaKO5bYRG3ZURuRxnetoOEa7kQ0QDn167S5YjY0niGpCaun x64Q== 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=OcsJNr7GGb9bAr8Y1C3w0n/ETC4xvGHTUHLJr+HIDlg=; b=WhDMFllQXM1kpzqJSesDavjLWduc4DIcBX1ovHcqVRaI2iFSVnpJKNkzqdtOIM02uR AMsK6V6oS2XSg7X+EREh+BAe1CiJBvN2EaQIGmCSriKXmjjI3+SMcLlTtRs/6zk4Sk6j 42Z7OyhJnQzUDZiH1kbBSvT8VtQZu4S5g/kFFzqCjGl4Lwqp5kPJ8Ya9wWJX4xxMC9Gm luTusvNCNMn6AGXRlt7ihIxRnjqj0KXoKxJG1ouETnp0JIgbGRbtrKOv/0fQcdOOq/MC F0r3fYYHp8/i58mkRDhKMMqNqQhrlLZCDB7A7uIC2g5q9W8Bu7bR5pRCNx7di65gW4sa 5QmA== X-Gm-Message-State: AHQUAubfSx7f+5hp3/Gu9V7FOGX4Oq0EGdAWxW25GffAtVhg8Xpotptw hon42s6Uap4NiGhGKpLBniE= X-Google-Smtp-Source: AHgI3IYWYw95nPX0eEvgIb10hGvemZ3fqufO49tQUon/y33TmM2rUhXM1l2dbvDbV3V38U7+emXrcg== X-Received: by 2002:a63:4b0a:: with SMTP id y10mr1316722pga.66.1550317088096; Sat, 16 Feb 2019 03:38:08 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id p6sm4967813pgd.69.2019.02.16.03.38.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:07 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:03 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 12/21] diff-parseopt: convert --output-* Date: Sat, 16 Feb 2019 18:36:46 +0700 Message-Id: <20190216113655.25728-13-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 also validates that the user specifies a single character in --output-indicator-*, not a string. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- Documentation/diff-options.txt | 10 +++++ diff.c | 71 +++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 058d93ec4f..d3e8d634b2 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -41,6 +41,16 @@ ifndef::git-format-patch[] Implies `-p`. endif::git-format-patch[] +--output=:: + Output to a specific file instead of stdout. + +--output-indicator-new=:: +--output-indicator-old=:: +--output-indicator-context=:: + Specify the character used to indicate new, old or context + lines in the generated patch. Normally they are '+', '-' and + ' ' respectively. + ifndef::git-format-patch[] --raw:: ifndef::git-log[] diff --git a/diff.c b/diff.c index b24f6825a1..8df396cb9a 100644 --- a/diff.c +++ b/diff.c @@ -4841,6 +4841,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg) return 1; } +static int diff_opt_char(const struct option *opt, + const char *arg, int unset) +{ + char *value = opt->value; + + BUG_ON_OPT_NEG(unset); + if (arg[1]) + return error(_("%s expects a character, got '%s'"), + opt->long_name, arg); + *value = arg[0]; + return 0; +} + static int diff_opt_compact_summary(const struct option *opt, const char *arg, int unset) { @@ -4872,6 +4885,23 @@ static int diff_opt_dirstat(const struct option *opt, 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) +{ + struct diff_options *options = opt->value; + char *path; + + BUG_ON_OPT_NEG(unset); + path = prefix_filename(ctx->prefix, arg); + options->file = xfopen(path, "w"); + options->close_file = 1; + if (options->use_color != GIT_COLOR_ALWAYS) + options->use_color = GIT_COLOR_NEVER; + free(path); + return 0; +} + static int diff_opt_unified(const struct option *opt, const char *arg, int unset) { @@ -4965,6 +4995,27 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "compact-summary", options, NULL, N_("generate compact summary in diffstat"), PARSE_OPT_NOARG, diff_opt_compact_summary), + OPT_CALLBACK_F(0, "output-indicator-new", + &options->output_indicators[OUTPUT_INDICATOR_NEW], + N_(""), + N_("specify the character to indicate a new line instead of '+'"), + PARSE_OPT_NONEG, diff_opt_char), + OPT_CALLBACK_F(0, "output-indicator-old", + &options->output_indicators[OUTPUT_INDICATOR_OLD], + N_(""), + N_("specify the character to indicate an old line instead of '-'"), + PARSE_OPT_NONEG, diff_opt_char), + OPT_CALLBACK_F(0, "output-indicator-context", + &options->output_indicators[OUTPUT_INDICATOR_CONTEXT], + N_(""), + N_("specify the character to indicate a context instead of ' '"), + PARSE_OPT_NONEG, diff_opt_char), + + OPT_GROUP(N_("Diff other options")), + { OPTION_CALLBACK, 0, "output", options, N_(""), + N_("Output to a specific file"), + PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, + OPT_END() }; @@ -4992,16 +5043,8 @@ int diff_opt_parse(struct diff_options *options, if (ac) return ac; - /* Output format options */ - if (skip_prefix(arg, "--output-indicator-new=", &arg)) - options->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0]; - else if (skip_prefix(arg, "--output-indicator-old=", &arg)) - options->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0]; - else if (skip_prefix(arg, "--output-indicator-context=", &arg)) - options->output_indicators[OUTPUT_INDICATOR_CONTEXT] = arg[0]; - /* renames options */ - else if (starts_with(arg, "-B") || + if (starts_with(arg, "-B") || skip_to_optional_arg(arg, "--break-rewrites", NULL)) { if ((options->break_opt = diff_scoreopt_parse(arg)) == -1) return error("invalid argument to -B: %s", arg+2); @@ -5242,15 +5285,7 @@ int diff_opt_parse(struct diff_options *options, else if (opt_arg(arg, '\0', "inter-hunk-context", &options->interhunkcontext)) ; - else if ((argcount = parse_long_opt("output", av, &optarg))) { - char *path = prefix_filename(prefix, optarg); - options->file = xfopen(path, "w"); - options->close_file = 1; - if (options->use_color != GIT_COLOR_ALWAYS) - options->use_color = GIT_COLOR_NEVER; - free(path); - return argcount; - } else + else return 0; return 1; } From patchwork Sat Feb 16 11:36: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: 10816211 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 04B9017D5 for ; Sat, 16 Feb 2019 11:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7ED02C986 for ; Sat, 16 Feb 2019 11:38:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC09D2CD46; Sat, 16 Feb 2019 11:38:15 +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 733862C986 for ; Sat, 16 Feb 2019 11:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbfBPLiO (ORCPT ); Sat, 16 Feb 2019 06:38:14 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33304 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLiO (ORCPT ); Sat, 16 Feb 2019 06:38:14 -0500 Received: by mail-pl1-f193.google.com with SMTP id y10so6314026plp.0 for ; Sat, 16 Feb 2019 03:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QR3StLo68L3DcTI6VH3Zla5jIJPXUw7zsQh6HluvRV0=; b=tz/RWw5EPvIQdOwCziagqz8wfa4d6+wGnPVkIBJO3EIyH+mXvBi1n26800s4wPcYTH eC/KuZTRYaDKNH12rI6J/a4X0sWBsQALQI59pL5wq1jl9klT1Oy7QrrRfUWJbEgb9M45 ZwAVxe3icmm/9Dh8CKF8RkW3BmoSOc2EgnYqBNFvApxs5eV0BpknJunMD50epXeVS3SK M1cvL0LvFFtZ0+tc7zAlm+8EbDWJ7/ggNXThetCnuZuCYrSPgCYrTSNfa2r7Vb7NciCp uuLM/qwAckC92L5ocIDUq1tl+KvolI9g7CNuOPOlIE1up1E6wxXrofAX6laMLQOX5UdO 7YFQ== 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=QR3StLo68L3DcTI6VH3Zla5jIJPXUw7zsQh6HluvRV0=; b=mmpZawaJ7jqohxB6JyvtpBh3DJ0vSi//8HiMW1bmy42tVw1v54f18ShX/G5CFQhCM0 pMwWZve5KuyDHFRZdTwwxC7vn1SQWJznOW43PfbTcWS2TwxfoFmI/4RC7NrqzMn+6iiy LSwM3BEEXCtq/XurNxEDSvyx4ZugDBpijuHfPg0gJrXPpg0Jp+lZYhqxb/6qHiAVn30G JgG+PCvQUJoQs2wt4iju/q9EMwjMLd5i7qvgu4Yzt/C7V8CRdX70N2Aw7Az/3nVGPybx 04nlszmPL5GfDth8RnmHfogklpqn/PqjlYh8Vwnhrnzzn95Bv3GCy7Rftu712r7ffVQu JL2g== X-Gm-Message-State: AHQUAuYXs0oW/9+0UjCAecqEsHizKnCB18s/Q7le2VpNCTBIPLlLm9NN o+oqNBlS6Jwb7vi7o6q4OmA= X-Google-Smtp-Source: AHgI3IbJByfD5AV4U54Cnyw3pwiQ/k3EWioVRiGTEdL3JaK2wSjs7MgYZYpeuY1DFhdA/3tq7cE8Mg== X-Received: by 2002:a17:902:584:: with SMTP id f4mr15536252plf.28.1550317093380; Sat, 16 Feb 2019 03:38:13 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 86sm18347938pfk.157.2019.02.16.03.38.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:12 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:08 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 13/21] diff-parseopt: convert -B|--break-rewrites Date: Sat, 16 Feb 2019 18:36:47 +0700 Message-Id: <20190216113655.25728-14-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 | 62 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/diff.c b/diff.c index 8df396cb9a..d2139082b7 100644 --- a/diff.c +++ b/diff.c @@ -4841,6 +4841,30 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg) return 1; } +static int diff_opt_break_rewrites(const struct option *opt, + const char *arg, int unset) +{ + int *break_opt = opt->value; + int opt1, opt2; + + BUG_ON_OPT_NEG(unset); + if (!arg) + arg = ""; + opt1 = parse_rename_score(&arg); + if (*arg == 0) + opt2 = 0; + else if (*arg != '/') + return error(_("%s expects / form"), opt->long_name); + else { + arg++; + opt2 = parse_rename_score(&arg); + } + if (*arg != 0) + return error(_("%s expects / form"), opt->long_name); + *break_opt = opt1 | (opt2 << 16); + return 0; +} + static int diff_opt_char(const struct option *opt, const char *arg, int unset) { @@ -5011,6 +5035,12 @@ static void prep_parse_options(struct diff_options *options) N_("specify the character to indicate a context instead of ' '"), PARSE_OPT_NONEG, diff_opt_char), + OPT_GROUP(N_("Diff rename options")), + OPT_CALLBACK_F('B', "break-rewrites", &options->break_opt, N_("[/]"), + N_("break complete rewrite changes into pairs of delete and create"), + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, + diff_opt_break_rewrites), + OPT_GROUP(N_("Diff other options")), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), @@ -5044,12 +5074,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* renames options */ - if (starts_with(arg, "-B") || - skip_to_optional_arg(arg, "--break-rewrites", NULL)) { - if ((options->break_opt = diff_scoreopt_parse(arg)) == -1) - return error("invalid argument to -B: %s", arg+2); - } - else if (starts_with(arg, "-M") || + if (starts_with(arg, "-M") || skip_to_optional_arg(arg, "--find-renames", NULL)) { if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) return error("invalid argument to -M: %s", arg+2); @@ -5328,17 +5353,14 @@ int parse_rename_score(const char **cp_p) static int diff_scoreopt_parse(const char *opt) { - int opt1, opt2, cmd; + int opt1, cmd; if (*opt++ != '-') return -1; cmd = *opt++; if (cmd == '-') { /* convert the long-form arguments into short-form versions */ - if (skip_prefix(opt, "break-rewrites", &opt)) { - if (*opt == 0 || *opt++ == '=') - cmd = 'B'; - } else if (skip_prefix(opt, "find-copies", &opt)) { + if (skip_prefix(opt, "find-copies", &opt)) { if (*opt == 0 || *opt++ == '=') cmd = 'C'; } else if (skip_prefix(opt, "find-renames", &opt)) { @@ -5346,25 +5368,13 @@ static int diff_scoreopt_parse(const char *opt) cmd = 'M'; } } - if (cmd != 'M' && cmd != 'C' && cmd != 'B') - return -1; /* that is not a -M, -C, or -B option */ + if (cmd != 'M' && cmd != 'C') + return -1; /* that is not a -M, or -C option */ opt1 = parse_rename_score(&opt); - if (cmd != 'B') - opt2 = 0; - else { - if (*opt == 0) - opt2 = 0; - else if (*opt != '/') - return -1; /* we expect -B80/99 or -B80 */ - else { - opt++; - opt2 = parse_rename_score(&opt); - } - } if (*opt != 0) return -1; - return opt1 | (opt2 << 16); + return opt1; } struct diff_queue_struct diff_queued_diff; From patchwork Sat Feb 16 11:36: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: 10816213 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 55889922 for ; Sat, 16 Feb 2019 11:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43E532C986 for ; Sat, 16 Feb 2019 11:38:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 387702CD46; Sat, 16 Feb 2019 11:38: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 CDB682C986 for ; Sat, 16 Feb 2019 11:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728563AbfBPLiT (ORCPT ); Sat, 16 Feb 2019 06:38:19 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38911 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLiT (ORCPT ); Sat, 16 Feb 2019 06:38:19 -0500 Received: by mail-pf1-f194.google.com with SMTP id q1so6141339pfi.5 for ; Sat, 16 Feb 2019 03:38:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MVvmZkonIwnPcZzsX4G74xwzpv/hgyMEJNRcgCwHJ3M=; b=iyGb6AHF2eRIfMZbVvKhfVWMcWEdUDBjrcqIUvb1fO2C/18/SVCHn0cc2ApdJ1aowM UvlrwkrbH2CQM6FZfm+y7jzTMrochpquKGs7XLsmo2sV91uoixYgDAeL5o9VzM5Iy18k EN4MTA08kdMOJ3nV14TSErzsAdlNuOFuwYa521qxiAGhYqpLQ/L+G24crHd6S7H/rOqv u20T/OECUWd6pg4OJdOi5k5D5M3bskrdS+xTBmn3igDk4sS8l0V6fZ9xeXJjaEcaQxOE YEtgyYh5viRDWKvG2dlLiOJ9XHP38FP9gf68UtL3k8v5XLwwJMZCOppgXnybpdrhpxL1 gu7A== 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=MVvmZkonIwnPcZzsX4G74xwzpv/hgyMEJNRcgCwHJ3M=; b=JWGztmiarttJSUdgw49jaDM/3NoMztO61VEhDRTP/v7d4U4Qw3YoQCiGmoErajZz4V Gn6LBdWq1et+dRTB0E3uPmJTXbJ9vJSEjqUJGrn01yA6QFhoPQer1iG727BwiI9QOcxv 4oBwhkG5zP1g/73ybACbQW6oFkefSuVtBrOxElqR1pzkRPQpHfmso5utgCXSi5N1vMkY HrMEBgFkI+W/MnOKYaOhyY576yeJnsATJhOo8hObVJp0KgL6PkGmkZzx81gyqpO5sRiQ RNGbFkv0uxj4XOlbI0SIuaIIKvyiVmrTq/foG2nUhTDcWN/B2i5r0KmRqFJC7LqIK63Y itjQ== X-Gm-Message-State: AHQUAuaZILgtOi2+svJvdd/3RYZ2bYWZy5/roS78sNOxusFunP4hNc7d dtJMS2yXhz7zqzoA0oUd+RI= X-Google-Smtp-Source: AHgI3Ibc8ZcIQnwRIL2bNJRZAIB3APH8vELBdlzDk6lBIsrKAx/KmagYFeVda1myYE1oCLlA3fo/Yg== X-Received: by 2002:a62:f201:: with SMTP id m1mr2793096pfh.97.1550317098385; Sat, 16 Feb 2019 03:38:18 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 67sm22331020pfl.175.2019.02.16.03.38.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:17 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:13 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 14/21] diff-parseopt: convert -M|--find-renames Date: Sat, 16 Feb 2019 18:36:48 +0700 Message-Id: <20190216113655.25728-15-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/diff.c b/diff.c index d2139082b7..2c904e0526 100644 --- a/diff.c +++ b/diff.c @@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt, return 0; } +static int diff_opt_find_renames(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + if (!arg) + arg = ""; + options->rename_score = parse_rename_score(&arg); + if (*arg != 0) + return error(_("invalid argument to %s"), opt->long_name); + + options->detect_rename = DIFF_DETECT_RENAME; + 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) @@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options) N_("break complete rewrite changes into pairs of delete and create"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_break_rewrites), + OPT_CALLBACK_F('M', "find-renames", options, N_(""), + N_("detect renames"), + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, + diff_opt_find_renames), OPT_GROUP(N_("Diff other options")), { OPTION_CALLBACK, 0, "output", options, N_(""), @@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* renames options */ - if (starts_with(arg, "-M") || - skip_to_optional_arg(arg, "--find-renames", NULL)) { - if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) - return error("invalid argument to -M: %s", arg+2); - options->detect_rename = DIFF_DETECT_RENAME; - } - else if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) { + if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) { options->irreversible_delete = 1; } else if (starts_with(arg, "-C") || @@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt) if (skip_prefix(opt, "find-copies", &opt)) { if (*opt == 0 || *opt++ == '=') cmd = 'C'; - } else if (skip_prefix(opt, "find-renames", &opt)) { - if (*opt == 0 || *opt++ == '=') - cmd = 'M'; } } - if (cmd != 'M' && cmd != 'C') - return -1; /* that is not a -M, or -C option */ + if (cmd != 'C') + return -1; /* that is not a -M option */ opt1 = parse_rename_score(&opt); if (*opt != 0) From patchwork Sat Feb 16 11:36: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: 10816215 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 8F39017D5 for ; Sat, 16 Feb 2019 11:38:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EB7F2C986 for ; Sat, 16 Feb 2019 11:38:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 735232CD46; Sat, 16 Feb 2019 11:38: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 1FABB2C986 for ; Sat, 16 Feb 2019 11:38:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728653AbfBPLiY (ORCPT ); Sat, 16 Feb 2019 06:38:24 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37984 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLiX (ORCPT ); Sat, 16 Feb 2019 06:38:23 -0500 Received: by mail-pg1-f195.google.com with SMTP id m2so3820704pgl.5 for ; Sat, 16 Feb 2019 03:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2fS6qKe7ncj36/kWfSsq6miHtCaj5G8Mn1SO3NOZXUU=; b=K0bJWGnQulV/UvdLmUk352RnY7nEXVByQ+/GNFktMQNCl9Hb7JefI5AZ1JCWj2rhXo 1NfdM+gK42eoGVI0OEH8E7Xm7XEzap2YpyXx0mwZo6TVA87e2mdISkYzTUVGfrwtPTtg 5fF+fl5wY5CN6QWAP4I54j4qQb4ebVb5TcHOztxP5yYKChw9EcT4/0SDFuJK4nvgPIo6 lCpuGVEb1zo7yV1qavyVW/+RRibEBU7g0me+grlVuuA65scA/OnaG8TmVSsw/EbjjjAw qSGH+38jjQ/h+AP8CnFRGhdClFVhicXEuK9EMQioO5lH+hVcUeVumxxCtOGBLbM586mY +ivA== 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=2fS6qKe7ncj36/kWfSsq6miHtCaj5G8Mn1SO3NOZXUU=; b=qZG3Vwk8HjDggVKO6g/2U5iUJ39wK/1IMnoatCAfwTTRiRd7jHptnxcGbTwGXcblZv EvYbrGMu/gFGbW1+Y5USbMDQhkK1Bh6asg8I9XGy24Ng6iFqsHR+en9OoFmZTQZzi4PE WyM5/5jImLDO4+m0N+XSOzKCp+2FwMGXGBcqfQoOoSVMExJ4UrgfehdS+8vhFbL2HXV2 qlndF2k30wxkRFzXn8IOB4xQukhTJt6E4Ku6CxQAZsgcMq1TFIKq4Iut+YFCEO61VpV+ Ox1BpPkHkxya7ymBpsAwyOmddJxxUvEugSboIhmv8g46ezTC88hlhBHEtzmMNhfYW1Xv 6Vdw== X-Gm-Message-State: AHQUAuYPI8R07I7UbLD0cEpPCK4sp0pNSoEfcgcrwGhio1J1P605I67I KtBlF0YACRfBQf7U3hVf+V8= X-Google-Smtp-Source: AHgI3IZfxFCS78OvMK3h5oPlNqJatpQsjUOtmJhTh7a8BPdGGMo8Kx+BQl0gChaSDDoluw9Rdzh6nw== X-Received: by 2002:a65:63d3:: with SMTP id n19mr9876653pgv.179.1550317103013; Sat, 16 Feb 2019 03:38:23 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id l22sm13813426pfj.179.2019.02.16.03.38.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:22 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:18 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 15/21] diff-parseopt: convert -D|--irreversible-delete Date: Sat, 16 Feb 2019 18:36:49 +0700 Message-Id: <20190216113655.25728-16-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index 2c904e0526..e51f6b3005 100644 --- a/diff.c +++ b/diff.c @@ -5060,6 +5060,9 @@ static void prep_parse_options(struct diff_options *options) N_("detect renames"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_find_renames), + OPT_SET_INT_F('D', "irreversible-delete", &options->irreversible_delete, + N_("omit the preimage for deletes"), + 1, PARSE_OPT_NONEG), OPT_GROUP(N_("Diff other options")), { OPTION_CALLBACK, 0, "output", options, N_(""), @@ -5094,10 +5097,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* renames options */ - if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) { - options->irreversible_delete = 1; - } - else if (starts_with(arg, "-C") || + if (starts_with(arg, "-C") || skip_to_optional_arg(arg, "--find-copies", NULL)) { if (options->detect_rename == DIFF_DETECT_COPY) options->flags.find_copies_harder = 1; From patchwork Sat Feb 16 11:36: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: 10816217 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 9C11917D5 for ; Sat, 16 Feb 2019 11:38:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B2C92C986 for ; Sat, 16 Feb 2019 11:38:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FC572CD46; Sat, 16 Feb 2019 11:38: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 19E852C986 for ; Sat, 16 Feb 2019 11:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728751AbfBPLi3 (ORCPT ); Sat, 16 Feb 2019 06:38:29 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37268 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLi2 (ORCPT ); Sat, 16 Feb 2019 06:38:28 -0500 Received: by mail-pg1-f193.google.com with SMTP id q206so6091789pgq.4 for ; Sat, 16 Feb 2019 03:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9wS7l3lDkdLp2a7i+No9GmpOp5QPRWvOhZ83m0I7B7c=; b=kfIHKz4skQ47YP0D6mIoH2xYAiYoCs1rgxzA5dRLzUKq+KlVikMbS8Eh6N5SITggWO oGJWKJUOcNhpmeRJ46mZMLAzWpZvJqE7qfGzjn1dVcPM2ZGoVTdRuTTFGM/XCGYf+DmQ IXOLQul0da3XFFFK83CiQ7ed4J8Vs0kLXKtfBnaCZxgK+6B9PH9UlhACRO1rToaOR1zi FNaV135TePsFh0Al/WliUDhbc5+kgDXeV27kA67Qa3e5x3m8od9I5Qnbl9avbJsY/Gd+ dFH0GCQMdhHqka+aKi9UNRWI05OHVGtcaDreQpP6dn3KYBCmI9yN0D02P1j9HzUC+crn cYSQ== 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=9wS7l3lDkdLp2a7i+No9GmpOp5QPRWvOhZ83m0I7B7c=; b=eqw8DTH1oVkHqVHlBM7gNvZIUmnYkA5PBkJVYzgPu6K9Ky0TW+06TYYP32g/ILAnC7 zsxNjX0p5idLK1zB6J4JAEVVIlydM6u0ntb0GSNxC6NE6q9e00pKn58A7oj6mGWbZ75c f1DRij3mFPrdDLhvg22Nj9eBOOPr0fr0MXNkhr1HN+pif0mOE+KQollgOCHYJh7mKfs+ zJmd97gJLJf1stD0runWrq803Ce5w9IeFR5AaOpp5LfZICTGOGjtZ5dPiIvahfqBpKbF 7frFfzxdxSmja2bVw02xENVrlVUcT5RKmfhK5cIX6lH/9g+Rf0oC5BYyC3NM1L/GLF5p 9h6A== X-Gm-Message-State: AHQUAubcHXlcJjJi8QKsIK0lP5R9uwzMi0UQ3MqLpdrx3Vv0Qttrtodv 4y1K0uhX6vwsKH7sUD69BIY= X-Google-Smtp-Source: AHgI3IbNBImN3GCi34S9UqvT1L2p9mWhkTAMcQWG2JKVs1Zy7P9srrVSaGnTJ8lNorpPsr9tScnceg== X-Received: by 2002:a62:61c3:: with SMTP id v186mr14604782pfb.55.1550317107876; Sat, 16 Feb 2019 03:38:27 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id e9sm4410868pfb.52.2019.02.16.03.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:27 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:23 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 16/21] diff-parseopt: convert -C|--find-copies Date: Sat, 16 Feb 2019 18:36:50 +0700 Message-Id: <20190216113655.25728-17-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 59 +++++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/diff.c b/diff.c index e51f6b3005..35bac115cc 100644 --- a/diff.c +++ b/diff.c @@ -4617,8 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va return 1; } -static int diff_scoreopt_parse(const char *opt); - static inline int short_opt(char opt, const char **argv, const char **optarg) { @@ -4909,6 +4907,26 @@ static int diff_opt_dirstat(const struct option *opt, return 0; } +static int diff_opt_find_copies(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + if (!arg) + arg = ""; + options->rename_score = parse_rename_score(&arg); + if (*arg != 0) + return error(_("invalid argument to %s"), opt->long_name); + + if (options->detect_rename == DIFF_DETECT_COPY) + options->flags.find_copies_harder = 1; + else + options->detect_rename = DIFF_DETECT_COPY; + + return 0; +} + static int diff_opt_find_renames(const struct option *opt, const char *arg, int unset) { @@ -5063,6 +5081,10 @@ static void prep_parse_options(struct diff_options *options) OPT_SET_INT_F('D', "irreversible-delete", &options->irreversible_delete, N_("omit the preimage for deletes"), 1, PARSE_OPT_NONEG), + OPT_CALLBACK_F('C', "find-copies", options, N_(""), + N_("detect copies"), + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, + diff_opt_find_copies), OPT_GROUP(N_("Diff other options")), { OPTION_CALLBACK, 0, "output", options, N_(""), @@ -5097,15 +5119,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* renames options */ - if (starts_with(arg, "-C") || - skip_to_optional_arg(arg, "--find-copies", NULL)) { - if (options->detect_rename == DIFF_DETECT_COPY) - options->flags.find_copies_harder = 1; - if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) - return error("invalid argument to -C: %s", arg+2); - options->detect_rename = DIFF_DETECT_COPY; - } - else if (!strcmp(arg, "--no-renames")) + if (!strcmp(arg, "--no-renames")) options->detect_rename = 0; else if (!strcmp(arg, "--rename-empty")) options->flags.rename_empty = 1; @@ -5365,29 +5379,6 @@ int parse_rename_score(const char **cp_p) return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale)); } -static int diff_scoreopt_parse(const char *opt) -{ - int opt1, cmd; - - if (*opt++ != '-') - return -1; - cmd = *opt++; - if (cmd == '-') { - /* convert the long-form arguments into short-form versions */ - if (skip_prefix(opt, "find-copies", &opt)) { - if (*opt == 0 || *opt++ == '=') - cmd = 'C'; - } - } - if (cmd != 'C') - return -1; /* that is not a -M option */ - - opt1 = parse_rename_score(&opt); - if (*opt != 0) - return -1; - return opt1; -} - struct diff_queue_struct diff_queued_diff; void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp) From patchwork Sat Feb 16 11:36: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: 10816219 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 26DEB922 for ; Sat, 16 Feb 2019 11:38:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1772B2C986 for ; Sat, 16 Feb 2019 11:38:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C0112CD46; Sat, 16 Feb 2019 11:38: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 B20962C986 for ; Sat, 16 Feb 2019 11:38:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727657AbfBPLid (ORCPT ); Sat, 16 Feb 2019 06:38:33 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37992 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLid (ORCPT ); Sat, 16 Feb 2019 06:38:33 -0500 Received: by mail-pg1-f194.google.com with SMTP id m2so3820816pgl.5 for ; Sat, 16 Feb 2019 03:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=09gBbJH/gC6sWBTh0UPkB5O7bzKTh1bIiViSzNotuRQ=; b=FmeMBhmFWWVYJ0XZKAbEahRcwNS9FOCso26Mv2PrB7FWKjCQvYVbiT9DTuoBVAq1Dz tMVW5JFsaOGfjL3bELlqWkEZ/L5h8teH84J5cfyFshcuBXSh+K+xvB6uDUprq8qZBCCs KAh3lyhQMVthPavAO8q/0U4dzr3HIVzNugel3n45OyO5FDxsbr95LenLkdhs7SElwAV3 j24zhM3YmmRIC8S4waitKc+iNnBeggR3SI3Cz7RZxdjUdXG2hb2SRc++AMsZueFwm9n6 VtibpskyzTJPg+UwXOB+3pExN46TnM4YVLfKjc61DghYC0YCJomh5TVglLGARtLaPnN3 HpUg== 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=09gBbJH/gC6sWBTh0UPkB5O7bzKTh1bIiViSzNotuRQ=; b=srODmTricfAb/TxSvF3Cbx/8Tl3g2Svj32jhZoCwM4eftd0hFuSPzodQ4TEjfdH2Ft Ofy2C0NDiUJ1bQFY+AlmCW90hnbtlUUYk293e8OZLyU6dsafYP3d9IipviFliL9tfxIK 8vhE+tKCYhMdPoBXSv4qvmrQoeSmyLckg/fGip6+rjCBfjHCgECGLx9I6RMFEUORcKxy nsA6EYQ9FD1DI3PtYJEmE/sfCBI3TolIShF/whewyEaMLQH1EJcKhh+Q1wrUKi2wwizt RvrRcE0d2od9Coq9tO9i0qssgH5tPwwe9HB3g5WhySSaF6J+ZLVq/UjZl9Wh1jG+AtRY x8Dw== X-Gm-Message-State: AHQUAuZrB5T0gsdsKuP0yc5gcYOWbXNf3z3ICI0AZuRSJCJmTTHDRM+D FSdGmSOwHIwBZlNUDRIqvm4= X-Google-Smtp-Source: AHgI3IbAtDhXjfFUspfl5Rx4mdxSBKQrOVmwQ3QuXb6FMaREGy7HjWHhiBFnUF0sEQKvXUPyv1/ICw== X-Received: by 2002:a63:1cd:: with SMTP id 196mr9826891pgb.58.1550317112573; Sat, 16 Feb 2019 03:38:32 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id g6sm9350599pgq.18.2019.02.16.03.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:32 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:28 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 17/21] diff-parseopt: convert --find-copies-harder Date: Sat, 16 Feb 2019 18:36:51 +0700 Message-Id: <20190216113655.25728-18-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 --no-find-copies-harder is also added on purpose (because I don't see why we should not have the --no- version for this) Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index 35bac115cc..abb1566f95 100644 --- a/diff.c +++ b/diff.c @@ -5085,6 +5085,8 @@ static void prep_parse_options(struct diff_options *options) N_("detect copies"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_find_copies), + OPT_BOOL(0, "find-copies-harder", &options->flags.find_copies_harder, + N_("use unmodified files as source to find copies")), OPT_GROUP(N_("Diff other options")), { OPTION_CALLBACK, 0, "output", options, N_(""), @@ -5191,8 +5193,6 @@ int diff_opt_parse(struct diff_options *options, options->flags.text = 1; else if (!strcmp(arg, "-R")) options->flags.reverse_diff = 1; - else if (!strcmp(arg, "--find-copies-harder")) - options->flags.find_copies_harder = 1; else if (!strcmp(arg, "--follow")) options->flags.follow_renames = 1; else if (!strcmp(arg, "--no-follow")) { From patchwork Sat Feb 16 11:36: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: 10816221 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 A3B8117D5 for ; Sat, 16 Feb 2019 11:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9351B2C986 for ; Sat, 16 Feb 2019 11:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84FED2CD46; Sat, 16 Feb 2019 11:38: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 1EA1D2C986 for ; Sat, 16 Feb 2019 11:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728742AbfBPLii (ORCPT ); Sat, 16 Feb 2019 06:38:38 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44821 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLih (ORCPT ); Sat, 16 Feb 2019 06:38:37 -0500 Received: by mail-pl1-f195.google.com with SMTP id c4so1254716pls.11 for ; Sat, 16 Feb 2019 03:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=96BmZKDLDkTkTsNXVRYDSFuD+YjHSWpGmq4aRJAEP4A=; b=QMngNw032/GitGTlutsxrW6qUmbz3aC1g6zhy5wS9eQJ8GMh5n4V1mH5eE2A97dEjX ihOmQbl+0IOGeq6xxQwsoKEDPvL18jg7n8k8k9w40/HB4eUOSXqOqd7o+D+/44hVRAS1 pzoy+vgFYRkjtvjw0auvvd1IX35UBd8QESXoyikfSUgwoikbWnifasG8Gyu+5GjmmMgO Ya0wt47+iSNcYk2Wk8niCQoB6fhPGBQQsQ8EzOG78BxQW/hEX2JiZ1guoJvmZC0c6OFy HY9SuFcVoCv8Cu7YN2lSTCmgdOxU5NLYUlznwDNINiHDN/L9v9ih1tbgrb+7LOpBInZU JxfA== 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=96BmZKDLDkTkTsNXVRYDSFuD+YjHSWpGmq4aRJAEP4A=; b=KgRbRvK9T1kQQBkP+F6fQNeYMR5v3y8kZrQpnHMGrDAcFTBK2ka7W0LRD8PfSjDwvq Htu7jYDFYssg9/7Grd+e+0cl3T/qDbhpTON0vssb1E7eaqwZGg10rniYl9LK9GY/j9Eh 9GoLXG+LgVfkc72QYTL7pGhvCUM6+Ft+caoxHv7XDCGc+1WDAELP2iGNk3WsFSQjwp5X Z+7CjYQ5E9OtgK264yPHfTM4aphynhHDEUWNYLjQRuh1hC6gqDGx/s8f/qW3eObsLRnq Mos2hRBj1S/BGB/a8J7vTtPIzTeuiluzSOVyq27mGohbv9tw9GPIAbLTLe7JdIIGw8YW 50QA== X-Gm-Message-State: AHQUAuZlV+YhhWU9MmbrgMfSsBhGpFXBcCW7Wisl6d3feKwokogNf9Ec VBEFOXqFX0Q7zXlQsstONpg= X-Google-Smtp-Source: AHgI3IbHkBtzSpghw/30pFbmeKMr1RtleZLaDsvIP0Xc9TWG9O0AhoGvyXUAQ97tT1HiD3QOi5TlSA== X-Received: by 2002:a17:902:8203:: with SMTP id x3mr15232680pln.285.1550317117357; Sat, 16 Feb 2019 03:38:37 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id n10sm15746512pfj.14.2019.02.16.03.38.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:36 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:32 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty Date: Sat, 16 Feb 2019 18:36:52 +0700 Message-Id: <20190216113655.25728-19-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 For --rename-empty, see 90d43b0768 (teach diffcore-rename to optionally ignore empty content - 2012-03-22) for more information. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- Documentation/diff-options.txt | 3 +++ diff.c | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index d3e8d634b2..4c0d40881b 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -392,6 +392,9 @@ endif::git-format-patch[] Turn off rename detection, even when the configuration file gives the default to do so. +--[no-]rename-empty:: + Whether to use empty blobs as rename source. + ifndef::git-format-patch[] --check:: Warn if changes introduce conflict markers or whitespace errors. diff --git a/diff.c b/diff.c index abb1566f95..d423a06b41 100644 --- a/diff.c +++ b/diff.c @@ -5087,6 +5087,11 @@ static void prep_parse_options(struct diff_options *options) diff_opt_find_copies), OPT_BOOL(0, "find-copies-harder", &options->flags.find_copies_harder, N_("use unmodified files as source to find copies")), + OPT_SET_INT_F(0, "no-renames", &options->detect_rename, + N_("disable rename detection"), + 0, PARSE_OPT_NONEG), + OPT_BOOL(0, "rename-empty", &options->flags.rename_empty, + N_("use empty blobs as rename source")), OPT_GROUP(N_("Diff other options")), { OPTION_CALLBACK, 0, "output", options, N_(""), @@ -5121,13 +5126,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* renames options */ - if (!strcmp(arg, "--no-renames")) - options->detect_rename = 0; - else if (!strcmp(arg, "--rename-empty")) - options->flags.rename_empty = 1; - else if (!strcmp(arg, "--no-rename-empty")) - options->flags.rename_empty = 0; - else if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) { + if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) { options->flags.relative_name = 1; if (arg) options->prefix = arg; From patchwork Sat Feb 16 11:36: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: 10816223 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 2340017D5 for ; Sat, 16 Feb 2019 11:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11CF92C986 for ; Sat, 16 Feb 2019 11:38:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 054982CD46; Sat, 16 Feb 2019 11:38:45 +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 A42B32C986 for ; Sat, 16 Feb 2019 11:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727967AbfBPLin (ORCPT ); Sat, 16 Feb 2019 06:38:43 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34964 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLin (ORCPT ); Sat, 16 Feb 2019 06:38:43 -0500 Received: by mail-pl1-f194.google.com with SMTP id p8so6304431plo.2 for ; Sat, 16 Feb 2019 03:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wnK3BWlLapvtxZt19q2j6NAGKixQw64MvhmtACFNv40=; b=TOlmJ5lGnaC2q79Thu4TrqglIRHvlq7+2tACqF1AqCzJguo1qnCXXNZzQ83SSX+cvA BP6GwrM5KisVKNR/pw+ZldLQlM5YBLQG9A6GB2whPFlmH4IH6KkL+UeMCU/X43QffHMk MUw5mr8ESaU8WjLCXm+vAopHYhwHOghWGexEsYuYSJdqkXIJ1VqGfTO7YKYms6NKou4L nGlQT2iQ8Ek71WSz57myWRKXhQv4fpLYcmbbnpdkqlykc0MnbSrGZ3jleBBo22L4qeKZ fj4pYE4c6bD4gZC3vP9gduffoFcA6WLem4vlnbtqMjiPv3cJGFK9mjhKIJN8tLcxyleK ehpA== 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=wnK3BWlLapvtxZt19q2j6NAGKixQw64MvhmtACFNv40=; b=rMU6Myu9Aqtxg/6HtYd5/1FkFOXYW/nJiyj4JAFXh4gm7/32+u39NYERF80cMBMKoJ P0VhcR44gKbHh6P2gl1RVT2ZFo/bN7f6+a3MK6Y9M0QN7R9t365rZyXd0AqJgSy9MVKr iIY8Ua3wP6EcLWG8mc/A3+b3Kt468TYXIEmw03i/5OQpUHJUiiiRKnYuOX5JcJv53PAO vwVO+A8tubiHs7BZR4FbPpLD9Z7V8r+QOQ6iKjZg9tewF9y0OJCcy+MzRPgC3wwDRcYt vg8SdJM4sYhQ7Za6aLy4hfh8ayOIlVVlQnpGsuJwf4nvJVjMrouqFm8eQfutWGO888j/ sYkw== X-Gm-Message-State: AHQUAuZsn01DtXQbIQK8xPJA2e65KXMPggunMREpOGdQwmt8+BnU6BxY CHIvArjQXUxNoK3I9G6G3YM= X-Google-Smtp-Source: AHgI3IZrxtBPAIfVVoyV5DXHvb9GvJAm9qshTyHph+yRRcWAjAC+g82HlqSUFnXiw7U5gdVcPkhVBg== X-Received: by 2002:a17:902:e789:: with SMTP id cp9mr3423838plb.127.1550317122554; Sat, 16 Feb 2019 03:38:42 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id d3sm26436347pfj.54.2019.02.16.03.38.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:41 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:37 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 19/21] diff-parseopt: convert --relative Date: Sat, 16 Feb 2019 18:36:53 +0700 Message-Id: <20190216113655.25728-20-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/diff.c b/diff.c index d423a06b41..b9c267a199 100644 --- a/diff.c +++ b/diff.c @@ -4960,6 +4960,18 @@ static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx, return 0; } +static int diff_opt_relative(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + BUG_ON_OPT_NEG(unset); + options->flags.relative_name = 1; + if (arg) + options->prefix = arg; + return 0; +} + static int diff_opt_unified(const struct option *opt, const char *arg, int unset) { @@ -5094,6 +5106,10 @@ static void prep_parse_options(struct diff_options *options) N_("use empty blobs as rename source")), OPT_GROUP(N_("Diff other options")), + OPT_CALLBACK_F(0, "relative", options, N_(""), + N_("when run from subdir, exclude changes outside and show relative paths"), + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, + diff_opt_relative), { OPTION_CALLBACK, 0, "output", options, N_(""), N_("Output to a specific file"), PARSE_OPT_NONEG, NULL, 0, diff_opt_output }, @@ -5125,15 +5141,8 @@ int diff_opt_parse(struct diff_options *options, if (ac) return ac; - /* renames options */ - if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) { - options->flags.relative_name = 1; - if (arg) - options->prefix = arg; - } - /* xdiff options */ - else if (!strcmp(arg, "--minimal")) + if (!strcmp(arg, "--minimal")) DIFF_XDL_SET(options, NEED_MINIMAL); else if (!strcmp(arg, "--no-minimal")) DIFF_XDL_CLR(options, NEED_MINIMAL); From patchwork Sat Feb 16 11:36: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: 10816225 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 8092B922 for ; Sat, 16 Feb 2019 11:38:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70CE92C986 for ; Sat, 16 Feb 2019 11:38:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6525E2CD46; Sat, 16 Feb 2019 11:38:49 +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 F34472C986 for ; Sat, 16 Feb 2019 11:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728171AbfBPLis (ORCPT ); Sat, 16 Feb 2019 06:38:48 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45798 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLir (ORCPT ); Sat, 16 Feb 2019 06:38:47 -0500 Received: by mail-pl1-f194.google.com with SMTP id r14so6281790pls.12 for ; Sat, 16 Feb 2019 03:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gMvAAPap4MOuPwjY/8dMWwCuqN95V4jJncI3pfUo9Bc=; b=DRmJerOSuOhdPx4m2ScYJSTNm1WboZL55QDfcF4mFId9aVKLAMC7WlMllVtwhdJ9ay 8Yd7OfQI+qy0HsuvtC3tk+C0PyxCgpHXK3WaEhlrmfzsIzHfKoeRoKqdfwKRAZCo52U8 bh6XhA3YV8e4NiGR0uxE5pkIIQLcQqj++8fS4Z9Eb/MNNChA5N+bnUSxnmbczxxE2d7k MUQg0dL93kurWsbSjkCCgFy8widSuu8EnRSZk0uLNGK3zGZMXRAuLkIsjl7FK9C5d7uZ p4JJfezywr8GKbcjiPXCjItuyYntJC6TeK9O0hyZ5hKWUatv7jEQgyvmbf8n20RZ3use hrWA== 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=gMvAAPap4MOuPwjY/8dMWwCuqN95V4jJncI3pfUo9Bc=; b=thaQB+s6f/Wt76qd6NgLZAVjhkRMjntMslfYOR/8/YuBn4Mh6QMWDGi/5aRggtI9zz at5vYyxtRdTvfrYHIv7mcwdkk8K5QNXcwnvmWdWyU4WmlKJ7/vRfkbi1oU8/2gcuI7CZ qhs8quryoZgBJQnljAqlV007z5bqRu8dhLr2b8Bi5TQ/RQ7yagYmHtAp1RnS76ZSsD29 HyI+/ssYuVvjHvNmIYUjdhTI2M812oMZFMCewqWGye0lH/Sb0mxpGdeZ0a2dLyA5KEnE RDivPhuEyDptjc9FUeccp6B0KxePfSWsO1fSo33LGHsfE+zqQRdDE/BG/pK/OxcpRcAb 6Vxw== X-Gm-Message-State: AHQUAuYGDEQmLp4bODDPmj7eLRy6gB/KI3Pq5BskUUmx1sv4Ksr+c58+ 6/lfAPqBzVAaRLgm4cP7A8w= X-Google-Smtp-Source: AHgI3IZm4PNd30R4Q859QJpCh4g98YWBlPV8jLYtcjIB8sT1IABu3gbk9KS6UvanbSkPFJ8XDpdLow== X-Received: by 2002:a17:902:6e0f:: with SMTP id u15mr14872009plk.175.1550317127184; Sat, 16 Feb 2019 03:38:47 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id u70sm13595485pfa.176.2019.02.16.03.38.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:46 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:42 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 20/21] diff-parseopt: convert --[no-]minimal Date: Sat, 16 Feb 2019 18:36:54 +0700 Message-Id: <20190216113655.25728-21-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/diff.c b/diff.c index b9c267a199..33492e754f 100644 --- a/diff.c +++ b/diff.c @@ -5105,6 +5105,11 @@ static void prep_parse_options(struct diff_options *options) OPT_BOOL(0, "rename-empty", &options->flags.rename_empty, N_("use empty blobs as rename source")), + OPT_GROUP(N_("Diff algorithm options")), + OPT_BIT(0, "minimal", &options->xdl_opts, + N_("produce the smallest possible diff"), + XDF_NEED_MINIMAL), + OPT_GROUP(N_("Diff other options")), OPT_CALLBACK_F(0, "relative", options, N_(""), N_("when run from subdir, exclude changes outside and show relative paths"), @@ -5142,11 +5147,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* xdiff options */ - if (!strcmp(arg, "--minimal")) - DIFF_XDL_SET(options, NEED_MINIMAL); - else if (!strcmp(arg, "--no-minimal")) - DIFF_XDL_CLR(options, NEED_MINIMAL); - else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space")) + if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space")) DIFF_XDL_SET(options, IGNORE_WHITESPACE); else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change")) DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE); From patchwork Sat Feb 16 11:36: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: 10816227 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 B78C4922 for ; Sat, 16 Feb 2019 11:38:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF672B9E0 for ; Sat, 16 Feb 2019 11:38:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9012E2B8E7; Sat, 16 Feb 2019 11:38:54 +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 219642A39D for ; Sat, 16 Feb 2019 11:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728288AbfBPLix (ORCPT ); Sat, 16 Feb 2019 06:38:53 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37916 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbfBPLiw (ORCPT ); Sat, 16 Feb 2019 06:38:52 -0500 Received: by mail-pf1-f194.google.com with SMTP id q1so6141676pfi.5 for ; Sat, 16 Feb 2019 03:38:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3Y9Q7F1CMGHiLXz2kVJQ1cOEqDO+g2fX8bdJPpCtwco=; b=mvi8TMxTjvUMhT7LJvkb9M5FOHFD05hYnQMbzK0C/D/8YzAXLFzuTJ4L/OsdWhEAN4 txMgvLB+0knfv2d3v7XJZnDK6WgY09WMJLprP98UV+HDWDnULnq8p2sOMTzR0IICtyMD hNBv7EtLoAbk6YBH08hq5Gxxy5hyJrLk4DJIPaUJKdOi1yyW9aze3sDAKKFqZ1qf++5G A0jYUTavZz4OZ9WHvuwI75Fi2ka5B0l8p5xuAzQ9z9uslcbB0C7siknTIaNOIlVhre3k YOJTp8aJrKFbRBljcfqC/ZTVRiFnZghydg6w4GIoWnJf8InEis/JS9h3xp3ds9ZgE4Fn yP4g== 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=3Y9Q7F1CMGHiLXz2kVJQ1cOEqDO+g2fX8bdJPpCtwco=; b=ME8gc0ZTJeh01fXiSXiwARMqwultZYh4tXKJQwILQyYjkgN/+DgAOePWklJDSsZg5u 0akMq2DyjC0QLAV3nCAYYHu5ZS3WFFcxS3BLfhllwO2AyHNZYOJve6LaoySb6sxEJD/X nckb71Ano4SEmPpyGjCQVMoD2Yh7STbhROPy2OQtdf2y5FLnMwajrqCR84wOz7e8pUxc F9iakKko3DXY7My2gugIfOGrtbv+3YpnCfZAbadn3mwQpl5FdfOyiBAnYs839jDm+ZjT EhbUcp+kLDCZCRhvFwdG38WNyOtcJVjdk2z3ZiWlTw54z1OM6rMyvNFBUsPXghOr5Zyj EFPw== X-Gm-Message-State: AHQUAubBxeD1+dlekwzMojrJQqmGgXmWP3AwYy02vOwQV9DyNDFZT7Ns wENjoyXRwL2Y9jrpvUw0hgY= X-Google-Smtp-Source: AHgI3IY3FJf2KtZEmJyaQdk4KRIpz6mUCHFn3H5G5MYjmtXLX26GluvxOniMbkGrB0s+vQ2/Sb6gUw== X-Received: by 2002:a65:6151:: with SMTP id o17mr9770095pgv.285.1550317132000; Sat, 16 Feb 2019 03:38:52 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id t65sm20832921pfi.117.2019.02.16.03.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Feb 2019 03:38:51 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Sat, 16 Feb 2019 18:38:47 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 21/21] diff-parseopt: convert --ignore-some-changes Date: Sat, 16 Feb 2019 18:36:55 +0700 Message-Id: <20190216113655.25728-22-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.328.g0e39304f8d In-Reply-To: <20190216113655.25728-1-pclouds@gmail.com> References: <20190207103326.10693-1-pclouds@gmail.com> <20190216113655.25728-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 Signed-off-by: Junio C Hamano --- diff.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/diff.c b/diff.c index 33492e754f..a63ee4a44d 100644 --- a/diff.c +++ b/diff.c @@ -5109,6 +5109,21 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT(0, "minimal", &options->xdl_opts, N_("produce the smallest possible diff"), XDF_NEED_MINIMAL), + OPT_BIT_F('w', "ignore-all-space", &options->xdl_opts, + N_("ignore whitespace when comparing lines"), + XDF_IGNORE_WHITESPACE, PARSE_OPT_NONEG), + OPT_BIT_F('b', "ignore-space-change", &options->xdl_opts, + N_("ignore changes in amount of whitespace"), + XDF_IGNORE_WHITESPACE_CHANGE, PARSE_OPT_NONEG), + OPT_BIT_F(0, "ignore-space-at-eol", &options->xdl_opts, + N_("ignore changes in whitespace at EOL"), + XDF_IGNORE_WHITESPACE_AT_EOL, PARSE_OPT_NONEG), + OPT_BIT_F(0, "ignore-cr-at-eol", &options->xdl_opts, + N_("ignore carrier-return at the end of line"), + XDF_IGNORE_CR_AT_EOL, PARSE_OPT_NONEG), + OPT_BIT_F(0, "ignore-blank-lines", &options->xdl_opts, + N_("ignore changes whose lines are all blank"), + XDF_IGNORE_BLANK_LINES, PARSE_OPT_NONEG), OPT_GROUP(N_("Diff other options")), OPT_CALLBACK_F(0, "relative", options, N_(""), @@ -5147,17 +5162,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* xdiff options */ - if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space")) - DIFF_XDL_SET(options, IGNORE_WHITESPACE); - else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change")) - DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE); - else if (!strcmp(arg, "--ignore-space-at-eol")) - DIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL); - else if (!strcmp(arg, "--ignore-cr-at-eol")) - DIFF_XDL_SET(options, IGNORE_CR_AT_EOL); - else if (!strcmp(arg, "--ignore-blank-lines")) - DIFF_XDL_SET(options, IGNORE_BLANK_LINES); - else if (!strcmp(arg, "--indent-heuristic")) + if (!strcmp(arg, "--indent-heuristic")) DIFF_XDL_SET(options, INDENT_HEURISTIC); else if (!strcmp(arg, "--no-indent-heuristic")) DIFF_XDL_CLR(options, INDENT_HEURISTIC);