From patchwork Thu Feb 21 11:16:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823711 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 3DA7F1805 for ; Thu, 21 Feb 2019 11:16:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E0733073D for ; Thu, 21 Feb 2019 11:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 219B030763; Thu, 21 Feb 2019 11:16:40 +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 C34E93073D for ; Thu, 21 Feb 2019 11:16:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726677AbfBULQi (ORCPT ); Thu, 21 Feb 2019 06:16:38 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43490 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbfBULQi (ORCPT ); Thu, 21 Feb 2019 06:16:38 -0500 Received: by mail-pf1-f196.google.com with SMTP id q17so13595153pfh.10 for ; Thu, 21 Feb 2019 03:16: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=h6Rd8cdfbn/liIv8brLBqkSFYPlE/LyzcDZp6mECtbc=; b=ISURRD/7/0SZl/Ilj8J9HCq8Ss+nF2/xMAaUMiMR6TQNgCEo9wNaIgctoF+Dp2xVq1 1ouxfJzYDmplOAxwfX5+rB0pzzoBaEH4J22NdV0JE8s1G5D7euT2jzHoNf/8Od0SrjAN 3YFxEsA8i/pa1pI11m2+Sza6lm+VYQL/cmHrCO4OXY6WAAj1h0NbJIlccBOAQo134M+u 8Zl5A96QTlXdw1bQF/a8+PZ/cFa0ofjlcqO36CUc8fj9UBqSviAir4+kIiM+boOMjuEr EuY1dxqOjDfiJdwfpUXwbnd+CvRogjvmnSwb8JVOuYnsUmcQnsOfRFYeCDZANXOASO0f uw1g== 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=h6Rd8cdfbn/liIv8brLBqkSFYPlE/LyzcDZp6mECtbc=; b=GPphmF3dSFGtNNzGIbbUawN5ktU9SYP1VI6JEWEcWGTPyirx7fALrIi4ayT3lw3Wnj mvtGgNlHapj0E8sgffo0ZD4z5URtcKTrmG4+DnbWWc7XqxtXcXQkviqyAr1gvaIfd79a NoAphwafk3J/WoiMz0pyduzmihNY9fX3SV8CUA4kNiikePiksEt/Z4esDXdGaBC6GcjG jngaVKFIEjcqtcPdK9M30gIjzK2EDCdBXgDqWLZqYD4LjKNY6ZbmMG7OT7daKcfOsX+R +rTZRNkK1JyXfXXM9D6CWgC1crBW8hbXB7rPBzZ6FJEbZc2FHm94O/Z11CB5aeHZC+ky XxZQ== X-Gm-Message-State: AHQUAuZPiAgGHlzR97AdknzAkPCb/2/sR/1NTErWGMPSYefOhnsaBnxv tZA9VU83Pwj87ha/cxzsaJKITtdL X-Google-Smtp-Source: AHgI3IZ+gOaXx85KBtQWzd9F12ISCOUmxQAnyrOd/kNNulobHMakAc6LOhhkk5hrvdYefzNpBIdc7w== X-Received: by 2002:a63:61c9:: with SMTP id v192mr34629974pgb.120.1550747797285; Thu, 21 Feb 2019 03:16:37 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id e63sm41182434pfc.47.2019.02.21.03.16.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:16:36 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:16:32 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 01/21] diff-parseopt: convert --patch-with-raw Date: Thu, 21 Feb 2019 18:16:01 +0700 Message-Id: <20190221111621.27180-2-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823713 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 BD69B13A4 for ; Thu, 21 Feb 2019 11:16:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8FE83075B for ; Thu, 21 Feb 2019 11:16:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D1CA307BF; Thu, 21 Feb 2019 11:16: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 462C03077F for ; Thu, 21 Feb 2019 11:16:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726729AbfBULQo (ORCPT ); Thu, 21 Feb 2019 06:16:44 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40200 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbfBULQn (ORCPT ); Thu, 21 Feb 2019 06:16:43 -0500 Received: by mail-pg1-f193.google.com with SMTP id u9so10110496pgo.7 for ; Thu, 21 Feb 2019 03:16:43 -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=NIC5BMrDA/jjPY8ux1gqOzAv6/Ta0xgWF86dLsG8TNU=; b=QJLFHHI+txyqPKb9fY+gtqw9CE/U7AKzh6pzVkzKXqsP5GTTEvPGxJ931+SOgb4KtU frS3m7ykZwBuqsf46H4s9weypMFQFfXIDgEoC1L6u6TKCvaJum2kWnDGC+4WBkMp5lZI dXnUY0+9Bq6oDfS1mP4jVR8M8g/F93qYW+WGZRdkzoFLYCJcOJNaXw6oq/rnfhRBBj1y rUEqbnGf0em2xvG0DtLMgqUp3X4R/w7dA/5uXBGqbWQEgin1RLkmLBgOL85NfxfHT0jG 3jQFlzZcRo9dFbo4cfjig7iiqYzNOpAuLRypBzKd2r5TqYqXHVQ7tRJ1tUvfcuTzyJns JV5g== 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=NIC5BMrDA/jjPY8ux1gqOzAv6/Ta0xgWF86dLsG8TNU=; b=ZPTVxjndslPoA6iZ57r0ajvjpj5+aaZ9GrzMF2yOEpvL+/sv9VPvYpQLGHaXKych+p ihapBOP4nZ4zPoEBLtRSo+SxfdpNMga62lz4jBSyx3PJzx3KWdfb2rBpVR27mQyf/mqw u+a3f6MQhwgJWxMeGF9J2jBpzBeGcSb8Rw2Gnnz+j8lYvhS07YLhgSlIrG/iY5G01fsJ vQQuGBl+y5cGnosKjDcC4FB1EOzP+008/syNwJFlO+v5BEtUwlFNC8CRgT0fKz/2HMzP KJNXyHVsSUylvSij9ZAw4h6twCZkahI5fUsFwHNj+4p1rgTKpV5TulXgWkFx3OCNCBty To7w== X-Gm-Message-State: AHQUAubXIY9GgdeZotLpNVQbj7kB8wzVAsKFXRyH/+UU4oCpLqQPVtby ekfBSnhaALzIazVQkRqcAcuwyaPB X-Google-Smtp-Source: AHgI3IaRaNZu7NCGprPD0GWG/ExqdYi+wVZ2raJsHNQiBB5Dpvt8MZP9Bt2citutgWb9Om+gzG+/TA== X-Received: by 2002:a63:575d:: with SMTP id h29mr19413752pgm.442.1550747802826; Thu, 21 Feb 2019 03:16:42 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id v15sm28363044pfa.75.2019.02.21.03.16.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:16:41 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:16:37 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 02/21] diff-parseopt: convert --numstat and --shortstat Date: Thu, 21 Feb 2019 18:16:02 +0700 Message-Id: <20190221111621.27180-3-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823715 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 D985413A4 for ; Thu, 21 Feb 2019 11:16:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA0A6283E7 for ; Thu, 21 Feb 2019 11:16:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE8DD3073D; Thu, 21 Feb 2019 11:16:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18EBF283E7 for ; Thu, 21 Feb 2019 11:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726755AbfBULQt (ORCPT ); Thu, 21 Feb 2019 06:16:49 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35277 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726737AbfBULQs (ORCPT ); Thu, 21 Feb 2019 06:16:48 -0500 Received: by mail-pg1-f194.google.com with SMTP id s198so13653174pgs.2 for ; Thu, 21 Feb 2019 03:16:48 -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=eKtFaj/7qrmko2KxgPeNx8BlYd+XqJ5Xd1/U7NqoTJ4=; b=RMwYI1vhtAOYMc8BKGhjrze4VomtHs55yPSg9B735KHOSYO9qPnpQD+ScV+U30DcCy wyXI2IvQIoyK13uOhZ9kfhda5ZOpt7SHRjXAKuDSpbQwEAObKjC4OmLBBGVpw1z0qMdh et8s/H7MNIh6ktzOaziae3EakPiWMh39QRpXcRoElJ8/m4SWiFLkivlFxWs6VCrTPT8m hmpXFfDUW55DMPi4phgreGhnH0gTV8SQAVxqQsmLdyLve94rou5PHubukTBsEDymKq1b vNIM/n1sikthl5US7rRrmpM8LUcMb2Qp895Zic3SDUF1ZOmKbGCLbZB4Mhox/Ji+AubG ZPUg== 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=eKtFaj/7qrmko2KxgPeNx8BlYd+XqJ5Xd1/U7NqoTJ4=; b=koIibB06htLZnUDE7h1cmWRhRIgopxoZ/NjbZifY8AQzwahbCCdGKNJ5ld3U/VlQ4i a/JA9VqATFe/wmJlWxaqtodNkxPFGlLyO4QDd9/LCXFWeVxOG0CPHeNHG3mzWt33qh+E 555Jenojr4j59DNLBby2md2nr0o/ChFtUtvq3gHWf69lqiS6NoDyz5zLz0ghGozzY4JI f+6/M6CJU+JwwZ5c77jWhlxSuEVRyaD2Qo3ZqhhF8isLebDX3FKpq8+f2OHNpqNLdjMh keJWuwIa8s0fyMhJQElDH4gaMeTNNgc/IgRzSa8X3CZVwnZesvCGsIVOZpwQgWOQT7Dd 33lw== X-Gm-Message-State: AHQUAuYPqD/NBgSAHorAxLpqbF1Z9h0zsab+GznXgGUx45Pe1rSZSzK8 0EG4rj+qEZJlprCZYzJh2R+166Gq X-Google-Smtp-Source: AHgI3IbCy3DsvUKrSWucr6WC9PTQRVXSyIW86KsXC83J1gaDSTCeQLmETXe/2S7QieArZnTNKBRdfg== X-Received: by 2002:a62:a504:: with SMTP id v4mr5990477pfm.22.1550747807712; Thu, 21 Feb 2019 03:16:47 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id v9sm32339743pfg.144.2019.02.21.03.16.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:16:46 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:16:43 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 03/21] diff-parseopt: convert --dirstat and friends Date: Thu, 21 Feb 2019 18:16:03 +0700 Message-Id: <20190221111621.27180-4-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 --- 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..7b81b852ca 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 Thu Feb 21 11:16:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823717 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 EC35B13A4 for ; Thu, 21 Feb 2019 11:16:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D97213074B for ; Thu, 21 Feb 2019 11:16:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDAD83077D; Thu, 21 Feb 2019 11:16:55 +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 416F43074B for ; Thu, 21 Feb 2019 11:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbfBULQy (ORCPT ); Thu, 21 Feb 2019 06:16:54 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45137 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726737AbfBULQx (ORCPT ); Thu, 21 Feb 2019 06:16:53 -0500 Received: by mail-pf1-f196.google.com with SMTP id v21so10599159pfm.12 for ; Thu, 21 Feb 2019 03:16:53 -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=lpT0u+8iKoG3m0VOYYQxgNYeB/azPfiKzplGnayoX1w=; b=bpOH2jtAHy+HY5HtZkvf0GEg/I0Ar6kx6jpe8qPRGzjrJR1QAMpGPaiOGlAchR7F1I F55N3+Qzrj5TcyAvkTNmJceZueo4Li/qjPGJD0gsq5tIkjAlCiQ6Qwz2WEZv7iQ0sq+A hQ2SVYgMKGLukGoIgiwUl51jVRyT32QcuPYy2ZSdbIOE3Bvjp5fdl3mKgbzc1pUXaL4F r/A9Zz0639+VOohLHXwMJvgoEBnEib7WVE35mc8wJUlIgw4YQ6VhPQXI9YzM8zvcMSsn bKHU794I6kb7SURo/nBabZRdRAG8rg8QyLGl6OP9TCYGv3l17MZI5masMO97hzyTte1e u5Rg== 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=lpT0u+8iKoG3m0VOYYQxgNYeB/azPfiKzplGnayoX1w=; b=V4eCljgD64wB4kgIpPCsmiSWf3StJsd3+mpAgXNHjGkoQyA6DjR524Z5ocWAmqoaIJ H6QS/mi8ehWS2q6libvjhj+F8pGkSx4eWz5N6kC1CDtc6soUKaSmN/HFh8uNrH/PtWfT xNB5bWluTHaVWELNseDlrHtvbiOdzTS43Sgz4P3QAtHcFo/bQ5AyOnJLybxSXrvrJcTe SPr/tRh4sjxTaxb947hUeyZeLIIq0kOzK+NyERAZgXvLcUXx7q+Pl/IQIjib1LVrCqEm 5HveU6K01abk1SWnT2ue/0jFZ7G/a7DzjxCg5RxrOCh9DN3ygpmHFcS1VqqHAM7ANH8E a6uw== X-Gm-Message-State: AHQUAuao+5jBfN3LUQKMBeSLRJeEmovbPRP7qQTIOcpvFS37aw5vxSWu zQ8LbhuZ95WzWCo/MhunbCHb7AV/ X-Google-Smtp-Source: AHgI3IbBfr+NOwsrTheW4YXn2WyjOjA62cCsIlHvah4Qjq8Uu7fvZl3d1uOoX7CpOlj4GDOznb7TSA== X-Received: by 2002:a65:614a:: with SMTP id o10mr34429510pgv.387.1550747812706; Thu, 21 Feb 2019 03:16:52 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id m67sm2405622pfj.70.2019.02.21.03.16.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:16:52 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:16:48 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 04/21] diff-parseopt: convert --check Date: Thu, 21 Feb 2019 18:16:04 +0700 Message-Id: <20190221111621.27180-5-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823719 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 E28B91805 for ; Thu, 21 Feb 2019 11:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C97C33073B for ; Thu, 21 Feb 2019 11:17:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB62C30837; Thu, 21 Feb 2019 11:17:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A78163078C for ; Thu, 21 Feb 2019 11:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727295AbfBULQ6 (ORCPT ); Thu, 21 Feb 2019 06:16:58 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33775 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726737AbfBULQ6 (ORCPT ); Thu, 21 Feb 2019 06:16:58 -0500 Received: by mail-pl1-f194.google.com with SMTP id y10so14046525plp.0 for ; Thu, 21 Feb 2019 03:16:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O74GZqR3azoivzcxrZ3hFRiAdXI5h4OdMGU0jydtGHM=; b=msGh02RkXxSSCyGGk8CSDBJeWIrTQwU0XGWMkgLHrNkfTlZ8A7eUA5paSyWZTl+mio WkTt+SQyx5uVPp9HvX8lrADmLlVrmqswpyQprwQMmpBGLxDMh+fcLqd4AXOrRC1WZXrR cRMXpwNF1E0mbueBrFqDS2KZVFV6gnIYPeN262yXk9xyagybBNr2vqNxmIItcauZ2fzT ttRVXDwbqjxOOXaiALupjmet0C9jEgXf8ZfkdsUWlStDEVAnVdfkNo+/mN0uxRImkBKF 11AbJkqU2/F+whF5QQ9jqayx4UVkVMMRNafOekHSu6LJZBe+/ULtJ9A7uJkboqZOOUGx Cjmg== 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=O74GZqR3azoivzcxrZ3hFRiAdXI5h4OdMGU0jydtGHM=; b=bZAIAaKqEvh9WZ0GJpmSGDUxiymN5MNol+HLHaQYF6Nur4WZsD4tbGVQZPAROR7uxW hoTidgjV78d/ATC9V7qlF1gy0GoCcMvXsX6Ms+kxPe7+XrfY7rqoRslmFE93SeFvHJq/ uYoyl0s3y/vYevS5yqdeOR8VyliQrE/oBaW9NbBCDlrmCgdu76Zyt0KUBQbbHltStXso wRtUQ5guGQw767O09zUsB9iX5bSibGsCr20c6InxuDkppYXFVMRf5EmD8tXaNKBogg5J WEGZeMBhcTqfIh8dYptmJWUymnWqOcjgD3SsSgYMhYb2X/3Bvmp2sSzfsra1myl52OYL CzkQ== X-Gm-Message-State: AHQUAuYgEFIDx+fK2JSxIVfkPCjCyAhkaYiNDV3YRI8VabCmQXryIbjf cYresyzIx15fXoAkDS2A3Z4UGoEf X-Google-Smtp-Source: AHgI3IYjQkuZ0jQMQnKsxxgBeAmaqnfFPBlH622e95rAJ/K5MMXUTYxAKkHLjhoPVWtJ41spnrZPGQ== X-Received: by 2002:a17:902:b784:: with SMTP id e4mr30500231pls.308.1550747817395; Thu, 21 Feb 2019 03:16:57 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 63sm13319765pfs.65.2019.02.21.03.16.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:16:56 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:16:53 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 05/21] diff-parseopt: convert --summary Date: Thu, 21 Feb 2019 18:16:05 +0700 Message-Id: <20190221111621.27180-6-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823721 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 9BBA71805 for ; Thu, 21 Feb 2019 11:17:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84B5830864 for ; Thu, 21 Feb 2019 11:17:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6228930865; Thu, 21 Feb 2019 11:17:07 +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 A21E7307FE for ; Thu, 21 Feb 2019 11:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726737AbfBULRD (ORCPT ); Thu, 21 Feb 2019 06:17:03 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44044 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726246AbfBULRD (ORCPT ); Thu, 21 Feb 2019 06:17:03 -0500 Received: by mail-pf1-f194.google.com with SMTP id a3so3782938pff.11 for ; Thu, 21 Feb 2019 03:17: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=QyRAtZBqzMDqFoHD9L2pCScc1lzNrXPO4apEFtQPuB8=; b=W7SXVy2vn2DLUXcWn7KDeLnI4rpgHJS65d1h/gsWrzzgzrdwmmFEV9970LK9MOJyoN rSMpyJN9tqjb6mWS3et3by/BXycCMues5EbecRjcjtA69gzVp6FLchQXOyVeCMGpZMOX hixjdM6C9HhhHc29O31cA46vJuXjpSpIc2AgclSOMUgEpDlKIArDw1I/yeqL3CzsFywh ZgxvU6wxcx7XSrJU0XnzbQukIDDlGSHRvG6xGcTtbgPe/a5lU7MMMcKH8YxO3MwpzEQR eyANywpa+IpbbkFOg8liXOMX84PrgCddB4pYOvs6+dMY0qnW4vDhpZ+8x23IwH96m7yR BgGw== 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=QyRAtZBqzMDqFoHD9L2pCScc1lzNrXPO4apEFtQPuB8=; b=Z3xFl3XMg9Lx+RqLtLBYPRtOWD1IpLXrxzY5pj1jLZexlvb1TIizkZdbfLeOuW42KM mJ+cb0S/hmA5aOtdNMWD7tvgM3Pq85f1geeEa4FyxVwFMKmjDYOSsfboJdTv+w04P+Iw 6GZwJl8K6F4lM6aQH4gcmEMeR+lA6aliDh+HA0rSQudc3ElF3+YjHB3g0JXx4YYa8DIW 9SkvzHtd8s4I8pijS3ZUycdjg7xZqMNCVAXNhLfNeEhHCl0DMgBQGl7c2lqhRaF6K5o/ YplvdMgJUaw4mjJwPYiE4y+FefgmuVlqR60877wG8PBgZVGToA7a0f/HU10h207FAsli xUHg== X-Gm-Message-State: AHQUAuZ8L0mvzlFFxui3tyHljCMvxs2BKa2VV5DlsxoK3WD+ae0ebQNU vlq0ShlXgYQaiRgpYsd3D8eMCOvx X-Google-Smtp-Source: AHgI3IbgRxnBPT1J9FNvewPQSlfFUrjHgTvorPq5Bl2JrxUSVYX/t0JwA88CiUL3mU+g6bCxu52Cfw== X-Received: by 2002:a63:4b0a:: with SMTP id y10mr25436927pga.66.1550747822581; Thu, 21 Feb 2019 03:17:02 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id b85sm30633080pfj.56.2019.02.21.03.16.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:01 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:16:57 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 06/21] diff-parseopt: convert --patch-with-stat Date: Thu, 21 Feb 2019 18:16:06 +0700 Message-Id: <20190221111621.27180-7-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823723 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 E25D213A4 for ; Thu, 21 Feb 2019 11:17:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2201307C8 for ; Thu, 21 Feb 2019 11:17:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C64D83075B; Thu, 21 Feb 2019 11:17: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 6E767304E6 for ; Thu, 21 Feb 2019 11:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbfBULRJ (ORCPT ); Thu, 21 Feb 2019 06:17:09 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38493 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbfBULRJ (ORCPT ); Thu, 21 Feb 2019 06:17:09 -0500 Received: by mail-pf1-f194.google.com with SMTP id n125so6319737pfn.5 for ; Thu, 21 Feb 2019 03:17: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=t1y+HyLvueKFGu8cPhQWWu2MxhbNOIiVvKdNy/Xiyj4=; b=XjFzA/WmIEiW2jKfHCp4K94I4V3t2j22GPnw43lmZmyoFlsmS3Q9YhiMtAzVK4GPIE kckVLhbNB3kU6sYC5RQRNPeRDVeq/fHleH8TNoadOwK+ewNLmYDooDhIZcnEdUjNcK92 ABtrfTyou6Swa6hC5SpXkdT3y3eV8wXypXoyuD3d1dyAJLlpkbuv5qhMKliw7NpaToA0 74Wn39155fevkQroxsvdwQRTeTQV5r4sGse5BZiZoVnt3fJkRCw/E6wN/yvQhxtV/kCF L0g/d0LptKQDG8DfluRBCLPVTzzNTAPwIXgDqw+bst4oUnF90C23h1UILX7+Ho3Pw8r3 1YBg== 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=t1y+HyLvueKFGu8cPhQWWu2MxhbNOIiVvKdNy/Xiyj4=; b=A31EyQNPAnlYmppjpXdYXg3rN3aMls49lJZ+lDlXG+1C2DTd5J2Q/WkPeo4sETm/Cl Zbmwkuopm6eFtfADuahfuLkS6NZ8mp6NsXHDzk2oanh7/qcqJcXf3rF8GdcBg3iQImje 0AA15X7K3t6AUTePyJzqOKPEGHzZx6PzGNOrVvOEI9MAhvy2uTuhVJHSk4Wi4BWNzk3q 0t2IDI/WDEg+TvpMSD4c9x9qc+64zt6SW1ZMTpRn3CQOGkzKy+rabNxbhb30PKJ1ppCb KolXyoowSMeGgmBw49q+LAgV6rv7ZTMuTvEpoxln7h84cRESgG7ZYvFHaYtPUqI7kYJK H7tg== X-Gm-Message-State: AHQUAuZDOFSL3NedaeaojxtBnl9l1xo+Jo8DDP/tJjqHf3SDYpbGpwjf d9Dt2UyM+wiQTx5uVW1Rf0IiXzoI X-Google-Smtp-Source: AHgI3IayZVGL2SRVUYqkhNqY/RVv6EpT5VEjCOMeXapRTd3291Edla1joddQE+PQwRWPbO7FfdvYPQ== X-Received: by 2002:a62:b608:: with SMTP id j8mr41027854pff.183.1550747828065; Thu, 21 Feb 2019 03:17:08 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id x1sm25274324pge.73.2019.02.21.03.17.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:06 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:02 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 07/21] diff-parseopt: convert --name-only Date: Thu, 21 Feb 2019 18:16:07 +0700 Message-Id: <20190221111621.27180-8-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823725 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 14C9B1805 for ; Thu, 21 Feb 2019 11:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04B223073B for ; Thu, 21 Feb 2019 11:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED73F30784; Thu, 21 Feb 2019 11:17: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 978D93074B for ; Thu, 21 Feb 2019 11:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727357AbfBULRO (ORCPT ); Thu, 21 Feb 2019 06:17:14 -0500 Received: from mail-pf1-f170.google.com ([209.85.210.170]:43312 "EHLO mail-pf1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbfBULRO (ORCPT ); Thu, 21 Feb 2019 06:17:14 -0500 Received: by mail-pf1-f170.google.com with SMTP id q17so13595822pfh.10 for ; Thu, 21 Feb 2019 03:17: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=X3KYPN3+Tdv5ZnbVUaHTegzuXkFIudtM6V9yBs8v7uA=; b=lr04lNeYv1vzmZKsZS9WU5K2EK3SSaJu8tNfA1vCbre2q/9p2kDt9UdrM+BLp9QYW6 0yGY6XjUgQiP6DNNOgz3ny2Qxoa0VgeuAMrOE46mzJZa4o8RyNlM42dG1g6ebwwCh+G+ xCHOTbWXgF6dBrLFEd1+0vzp01/teoJDVJYdussO0mC4nH0O2YzffiBsl2jOyVxt8qy7 OmOew8jFasC9eZM+9/yhaR/dzDNuceus96fAdpQUWnZtpGS4M12eTUcOoBfGg1Idh7BW f2T7bWZrMxy+9tV34OOLnuww0FLK9ObjIE3YpuiE7A5xunHzVBikNFiq8J4gr1HgYQr1 5WAA== 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=X3KYPN3+Tdv5ZnbVUaHTegzuXkFIudtM6V9yBs8v7uA=; b=Ioe0QkTpN2s3/zNZnsk+4p1uodLHLmCo2oFoz4bwpmk+zCa/vBAsTJdxT4dC7aLiU0 tMI5wug5rnxonNXTFJbQyhKDRk+Vp6Wr6BActDK1mlCRxeZHFSRB5JIeaOOQzN1AfgFU pfQKrtq7GqFyPlSPReOizaPbUMgUv7/azh+HHbowqF+hkJmeuijEZt5AiJW3MHv+VW/O QAKJoqjQHZ/HBGDbz141kSOttRTtG3LWQqWqtT5qWyhzh2tIRnN5yQcxKRqRxoZmDLNV KIXijNMTJIZsl6W8HvE759XpstvUzYQbIb9wGrFW8haisumCJldOIMt2PCwpXPNhxMv6 SiQA== X-Gm-Message-State: AHQUAuZ/00iEssNdsG4Fe+IF8REmaHaNuAqjAj88nJPZITb0yaZqHHRW CwSqMENy++61o+d0TEIdGTwGmiLP X-Google-Smtp-Source: AHgI3IaG3m5SjR+J1PHP0GnS1ChR7M7V4VbBaXXce5OoKtIPzfJsgKeXruL3nKGQ58aCvXudoxDnhQ== X-Received: by 2002:a63:680a:: with SMTP id d10mr1306542pgc.46.1550747833142; Thu, 21 Feb 2019 03:17:13 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id z4sm24599223pgu.10.2019.02.21.03.17.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:12 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:08 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 08/21] diff-parseopt: convert --name-status Date: Thu, 21 Feb 2019 18:16:08 +0700 Message-Id: <20190221111621.27180-9-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823727 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 B212C13A4 for ; Thu, 21 Feb 2019 11:17:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A10EB307BF for ; Thu, 21 Feb 2019 11:17:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9584C3075B; Thu, 21 Feb 2019 11:17:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A2B33057D for ; Thu, 21 Feb 2019 11:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727382AbfBULRT (ORCPT ); Thu, 21 Feb 2019 06:17:19 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35677 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbfBULRT (ORCPT ); Thu, 21 Feb 2019 06:17:19 -0500 Received: by mail-pf1-f193.google.com with SMTP id j5so9096996pfa.2 for ; Thu, 21 Feb 2019 03:17: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=JdpWqYqmcMHMXCmm61a2Q6WAgqhYXu5N4iZFEj9jTX8=; b=HOiKlFKVbFgK2jq21fiaP+ki91UEuq7kzTFUVZEeaJwPB7vAaoSKNekfJl6J8c66RE A0FlrZ6/CnyT0zGMshN65JYVob9NGwvt4onFlVjbe7XqAiSN2Qb1j2nngaqMeXfWTSZV iZrnsEo6bzJBcbrwyDh2AE+9/QwqXCyRq1eAMxWIFk3MEBXDa5PuA08PhQpeQo4wxYQC rHI1t/88prDjCrnkKFylEr9x6+xu3odfER5QDUVrV1IQfl4wl0UvyZsE4gGLoYhG0eZX Z4x/R74qO5QBDaPu7rR6v3WquWz0Jj4bNOWBK2U74igN8Qj/P8my8TvnTUjzVZYcWaT/ U63A== 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=JdpWqYqmcMHMXCmm61a2Q6WAgqhYXu5N4iZFEj9jTX8=; b=PSFbE2TU/IeCpN0uOM6IxoyOQPSqSsWuDRgT/VLLMbstSrhYB17kkgZl0Q3vVG80Dn uHh84U1cghjhA6rzn33L8Hh/vh5U2byP4Aj9Wh3U9bwjVQ0qbeHiE+nYd4CQ0TSyeeOu wb1suc8W2ypCO4h7g3tv0fVo1Tx+KpTFiDNFYGtQJGaFh0RxcE6h62+40BOwt4rIaqvS 04CFDxx+tCQIbJhpMf5oVpOjDitKQWqgtkg6RmbVSYXo2CszBEEO0M1LlEDekDqtI3cg Jf8PMcUerIk8dx6iPu4XoNqgh+bHOBjI1S1qjAT1k6ORkx8Xqo0++qbse9Qnvoa1A/uJ kT7Q== X-Gm-Message-State: AHQUAuYy6oDMw0XOCj91UGRUUdyzKHCBD8VLP6HDwmYjTcWVKsWYRI2Q TycpAeMfxw7+ex6qAbr7IhS2y2ib X-Google-Smtp-Source: AHgI3IYbL7ibwUFeBhI7BTmScb06OQO68AXn43VjVXqtdMPVgNV1f9I5jfZlC731UvSN7zOEbE085w== X-Received: by 2002:a62:398d:: with SMTP id u13mr39617135pfj.32.1550747837958; Thu, 21 Feb 2019 03:17:17 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id o2sm30882638pgq.29.2019.02.21.03.17.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:17 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:13 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 09/21] diff-parseopt: convert -s|--no-patch Date: Thu, 21 Feb 2019 18:16:09 +0700 Message-Id: <20190221111621.27180-10-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823731 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 D60E713A4 for ; Thu, 21 Feb 2019 11:17:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C28123073D for ; Thu, 21 Feb 2019 11:17:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B72393074B; Thu, 21 Feb 2019 11:17: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 24BD2307C3 for ; Thu, 21 Feb 2019 11:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727457AbfBULRY (ORCPT ); Thu, 21 Feb 2019 06:17:24 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36965 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbfBULRX (ORCPT ); Thu, 21 Feb 2019 06:17:23 -0500 Received: by mail-pl1-f194.google.com with SMTP id q3so6650213pll.4 for ; Thu, 21 Feb 2019 03:17: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=EEq+eIXonT0BQZL+ZgiZjh9AEaB+/hyZRQt9vqFQMOU=; b=Eh5XTKb9oxpEhNMvrY7gudzXLPaYOsqLC9kSdaYrRJzyrYCMZBOc/ACqgPF5QBoa4z G9ox0iLoSn6SCpujx9kSL5gBbvrC9jpKReBIHdU4I9s1sKdFHy24F3kbWuW6PdIczlTY Viq65oKBIZak5C8AKAK8h6yVIQ1Xa0IJhNo119sOKQHSoRV+3YOD9uwaFOxWrK6IoJZu xPveHO7+Eljhrz4hMN1zpX2+FFV+TVLJfag0svdyRsPPGmXrInT9CDst0IxL8HI6R2Pa u2Y9x8Cplw0gpKu4PAGWEeOB/yOjvqg1oA6YjU7wmAeezu/58ExMauWPcLvBtDwMGJVB hGIA== 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=EEq+eIXonT0BQZL+ZgiZjh9AEaB+/hyZRQt9vqFQMOU=; b=rp2JpD4kyEwI1RTOl0mHD1LxpqvnRa9FqDyIf+JUbpZF/9KPIUawaV2zjkO98F2s5L e+l8TlPgQHRFdiO/WSmu3VCAKVhreQok8ierl03udPOJvqbLZQJk5VWUXZgdd2yZemm9 RGoNWtMk29R2Mwl+myS/ws8FcxJBQtjm0HBeqnVhGsD78Pd1ef0NWZnSSD5ek25pZO8+ QOOAQ6xHfqcD7T20tH0erMVn8m3wJcJY655n6h1mhNj/uCHNuVvOo69+2tLJoHJTk4VG yT035ubi4TeinrAmHv+Dh9e1DfEoFjp5UGZ0ecDHUlyhv/ZWntLc2Wbf3sx4NFGujev+ LZiw== X-Gm-Message-State: AHQUAuZF/6HpIbr8taE5J/ZDMnohcFoKUZyCHWYUjcFY+vo4TFLAJeVe C7bRYOzdKlEBDDAGPhCxoeZv6mYy X-Google-Smtp-Source: AHgI3IbMeegpYwPv3VnHtotB++FRsqskA8BR4sVSVOv/fDlEslTlh+PWw1lwYvAW3gMVnoqzK5vhbA== X-Received: by 2002:a17:902:296a:: with SMTP id g97mr42266730plb.317.1550747842920; Thu, 21 Feb 2019 03:17:22 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id k26sm36204358pfb.87.2019.02.21.03.17.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:22 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:18 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 10/21] diff-parseopt: convert --stat* Date: Thu, 21 Feb 2019 18:16:10 +0700 Message-Id: <20190221111621.27180-11-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823733 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 5526C1805 for ; Thu, 21 Feb 2019 11:17:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44BFE3073D for ; Thu, 21 Feb 2019 11:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39232307B6; Thu, 21 Feb 2019 11:17: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 D6B223075B for ; Thu, 21 Feb 2019 11:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727468AbfBULR2 (ORCPT ); Thu, 21 Feb 2019 06:17:28 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35098 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbfBULR2 (ORCPT ); Thu, 21 Feb 2019 06:17:28 -0500 Received: by mail-pl1-f196.google.com with SMTP id p19so2806185plo.2 for ; Thu, 21 Feb 2019 03:17: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=tyd7LIgbA7LF7r84I4VnYjXpCkPhMnAtEwWVikbczkI=; b=EUpJxBPrIgQGWDar8/AiJaRwf/4nz7EZ2M4MvsRRfq8vytxrZYx2rpHlRCt0IYynDK ryFD6DstCdqaXMgwauUEVFQsEcxBBuQbcyQAS9Me0GbZ6GYexpfzlDYaufYTYDwhX0lE kX7mdCSNuxQpPSgQ1EfOaNNR1s2FcSVgnkU19Mr+AMignHykH7bYKljq7QHTXFhmNmyo Bp65dVoOvqjjenQY+qjWDXBXpG5V+f3Sfs+6KUSmUetXIG5EDH/nOOW5bOplWrOOCrND XEKhZQK9bIgRm/p17eOTO8jVQdg/cn89KIZW1k0R21+M3rmSHtLtpa0kTE2pqbxUNXcM BRpg== 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=tyd7LIgbA7LF7r84I4VnYjXpCkPhMnAtEwWVikbczkI=; b=pialzFRc0nXdtpBM/xsA1NU5kVCW8TtN2troz0qlokOMDZHs+/WZdVoNsdQnn9D0sD atc2FdyEBWwFT2P9sHFO9gZm0NyGN7wn5xRv3JkfiVbPAG7q9m4ScgKfcpDcF/8UlIbk D+GqRY+Z7vH0M6sHd/LynR2+ez5PawxrhtgDHGO8gHghr7P9QudG6kMCNObFssZUEsnI OT91p50AtGarRpEUHkQy/y7kAxK5BNXXkHDM+hFl28XvD96CQ5/RUwVk5+y4inFzDUJl av8OFLRoVh9i87Jlb01xnHFRIln6g1Z5CYWcq+CLwvUlILk/WdeAVWLKaILL6pTYqTR3 kAiQ== X-Gm-Message-State: AHQUAuYQutnVy1OXaUo8Mbw735xu2Z2qbwSbLuyKYWjT79MzArayQmqP 7BHMT1XDFkbNKzYSaSGEIb/nMzHO X-Google-Smtp-Source: AHgI3IabyE1nlb1dsPExNiULUadGM8uH+CWBiyQXkcv8EHasDKL3y6etmLySIOgbQR6+btVrog5O1Q== X-Received: by 2002:a17:902:8485:: with SMTP id c5mr11817449plo.67.1550747847832; Thu, 21 Feb 2019 03:17:27 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id k3sm24466801pfi.129.2019.02.21.03.17.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:27 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:23 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 11/21] diff-parseopt: convert --[no-]compact-summary Date: Thu, 21 Feb 2019 18:16:11 +0700 Message-Id: <20190221111621.27180-12-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823735 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 ABABC1805 for ; Thu, 21 Feb 2019 11:17:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B3033075B for ; Thu, 21 Feb 2019 11:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F9513077D; Thu, 21 Feb 2019 11:17:36 +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 07900303EA for ; Thu, 21 Feb 2019 11:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727473AbfBULRf (ORCPT ); Thu, 21 Feb 2019 06:17:35 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37431 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbfBULRe (ORCPT ); Thu, 21 Feb 2019 06:17:34 -0500 Received: by mail-pf1-f194.google.com with SMTP id s22so13612978pfh.4 for ; Thu, 21 Feb 2019 03:17:34 -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=pCPBEqBaZhwujG3R7wWeThIiOsXE1NPjaQURPeeq2fs=; b=YZSSsUco21L6T7RHPWkd8IW0lOZSAnKxRlxXSDJFpiSh9mMrz8jwfLn7BZAoNHTwSv 8kwsq2vpMLTsY2tXhuu0qi2HhOHUmKyerdpKNMPgnvgfyw2JlhyetRV8CA9xZd2igrl3 gD1sxBQPrvtngM3o+rF6+j9jjfhSTp/QQeEtHHQf77IlI6mEJPlOvMk06Am3Ceasfe/V QqlPmQw3kTQBs37JfxIACRebb4LE8eDH/WluzgsUa7cgSHUWfUJbnt3MZY55ndShVnd/ Qnvk4PcQVxHFEP4rGiepwpmlOq8DD+IOMJmehQ4LwJzc0dnEoVVLjoFItiSzdXC/nSzq yg+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pCPBEqBaZhwujG3R7wWeThIiOsXE1NPjaQURPeeq2fs=; b=nNDVxpc0Uz91VfbGNT3Wgg6zS3tfyNrVKrClUvDyvr8k38qClAFP8NEIXo2A14Iio1 FM5smkKby+DtO8iJ8bgUgoevv2YBavgMfKyhW9ZSGa7EARRTy12bNfKMXNskuuZLtP+t asaFACAye34xJnIbteI4EBKS3gR5GEPoyCpqsf8UvVBNe9RtVa0QnCYNGwEjsysb44ZT YsL2l2ZWc9wScsvc86DGAasKaPNQM2FjED7XVph63CCCWzW6aWmrAIxsHfcY9AE6g9sX GkSx4vOfDCBWfTZx9JLlp08XaFk2kai2gDv69Aa5Oy1qW1Gp2jA1KYfVwJoI1Z1QM5Bx RNNw== X-Gm-Message-State: AHQUAuav6QNOatWx63M+yq4s7EqosD/o03CY5h+yEO4TaGT4ZowPFDFe bmB6qb4YTTBVY0r+chdK+fvMa2DZ X-Google-Smtp-Source: AHgI3IbpKofrZ236c43cNZuhXbdTgkALw9J+4ar8wywRg2uWgYgX07EKmlTXm1s2fiaFfI7/S2QTxw== X-Received: by 2002:aa7:8150:: with SMTP id d16mr17015938pfn.172.1550747853552; Thu, 21 Feb 2019 03:17:33 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id u184sm616809pgd.13.2019.02.21.03.17.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:32 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:28 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 12/21] diff-parseopt: convert --output-* Date: Thu, 21 Feb 2019 18:16:12 +0700 Message-Id: <20190221111621.27180-13-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 7b81b852ca..56b731eae5 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 Thu Feb 21 11:16:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823737 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 D54A81805 for ; Thu, 21 Feb 2019 11:17:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C58D1283E7 for ; Thu, 21 Feb 2019 11:17:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9F3C3078C; Thu, 21 Feb 2019 11:17:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C27C3074B for ; Thu, 21 Feb 2019 11:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727525AbfBULRk (ORCPT ); Thu, 21 Feb 2019 06:17:40 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40286 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbfBULRj (ORCPT ); Thu, 21 Feb 2019 06:17:39 -0500 Received: by mail-pf1-f196.google.com with SMTP id h1so13592940pfo.7 for ; Thu, 21 Feb 2019 03:17:39 -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=Ewaq1kI/Jr3F1GWGzVU4IXs35xSV8NqNiU3WZvnDUx4=; b=DlG+mzSzEtZOdshktB8hgFQB+vyD0+Uj6TMbiTgE6O8f4pVllRY5UZ7Y1Cv8Upl/y3 hlZxqNwE7nura5XSSpKRPAzoCctlbR7CBHENvKYtb9nIDc6nEVH/SmksK2Tr6Yb3CAZC b6XcrqvbhBBtQVeNz2RBbFYh/hgZojibXx8924WI4Vj9Lu/EGqNuNi3804l1+F98zw/a qDCx0LgObr9gt//l4UIIK+cmgpO++E9SAcrYsNtvwqrbN6A3/NeErsXNm8yOSQ4OvAwl +he09TmxUOnEcqoEPbbqQX+hHG91CgL8tJuJOzuFLfflEuG+DgmlRzGDJowinlFFcHcb PjnA== 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=Ewaq1kI/Jr3F1GWGzVU4IXs35xSV8NqNiU3WZvnDUx4=; b=hBSUvOffiBdG5TxXcw30LTMese+FWvXghgMw9szmsUK3mvJ0i9q7XoonbM83vib+Ep lc8rlVdc/LpS9PXUQ5d8IBtT7RtXVaPrZy5hGHkchkz3UGs//JeR2XpwNXK5R6JpqmRh +0N3iZEQqNYgb1EpncDswOSeaiQP8zVuSMzagCWCwNGI3c5nyrfQPzTDLexNOmvJldEA UtPQrDWpUg8d2LxeIrfC/D5zaDqD+vuL+zwKdm0MkFxR59eHqUVYYiGzdDdFeVVDTaMi qddL6UV+aK4oIMf6OceTTCcuwQZfaE/N1gy+JM570cb70KeZ3ALafPPfXeJtqUqVep18 zjug== X-Gm-Message-State: AHQUAua8gEk1o4iAVc+QFnQXdE5tyQtEkQO3T5aKJbeYY4E63CmlBp5s j2ndP/ZdrVSdEdzFG8FbouAruL7E X-Google-Smtp-Source: AHgI3IY3o3gIqN2gHGjAWk5xzglRv5Yl/ghafaMclx3ZniXi71vpDnj4HfCmdPit8cCQu9U4oz3Xeg== X-Received: by 2002:a63:5813:: with SMTP id m19mr34017447pgb.294.1550747858846; Thu, 21 Feb 2019 03:17:38 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id f6sm34171320pfc.88.2019.02.21.03.17.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:37 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:33 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 13/21] diff-parseopt: convert -B|--break-rewrites Date: Thu, 21 Feb 2019 18:16:13 +0700 Message-Id: <20190221111621.27180-14-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 | 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 Thu Feb 21 11:16:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823741 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 BC3A013A4 for ; Thu, 21 Feb 2019 11:17:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD65130763 for ; Thu, 21 Feb 2019 11:17:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABD1C307B6; Thu, 21 Feb 2019 11:17: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 4C06930763 for ; Thu, 21 Feb 2019 11:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727532AbfBULRp (ORCPT ); Thu, 21 Feb 2019 06:17:45 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43596 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727527AbfBULRp (ORCPT ); Thu, 21 Feb 2019 06:17:45 -0500 Received: by mail-pf1-f196.google.com with SMTP id q17so13596419pfh.10 for ; Thu, 21 Feb 2019 03:17: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=eMfHUqCAVCI4ZbqEwjqUPBY9f95j0/Ci5hjPvacspYw=; b=NYwvz+hQAwDbeBF+CNSI0y3bED75EjP2vZYhtfLBkWDbZkvtJG/bfSPDuc4KztlA8Q jcEMjZ0Iv3jl3ogD1opAGz3Lx1IEtPoCOg9QFx8VyEPxfWHeC4n1OKWBTCCO4GWcLjtQ lAnCQufsVm+xPang09y01bgheCzdi0iAJUcWfqjBz4riYPEoFoom/Q4I3mswF63IKI1i vXZmUAdLoweLFFSvF3+xWAyCshZOj/VCuGQvqKKZ2hye1parVnzFUgk/++uy0sk+lRjH V1Ax0cchHGMsX5jxdCQe3uEM+wEzIUs62e6MK2nJBOExAhVS3nMh5lOk0nwSvfmotjKG XR9g== 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=eMfHUqCAVCI4ZbqEwjqUPBY9f95j0/Ci5hjPvacspYw=; b=o5MdD2VMZV6jH8umO4/l1glVG/8/s7sQhYeBBzTFof8tsSSvB35ioy3icTt45iCNJR ffhxcgZpPIG/Dg5qn9o5qxr9KzxPnSLlD7hgorDKkpmEUvBMNRQ8rmEWyTJbcE8qCsxN xmiNJC6Nl8EqH0OIbOViP2NwALKm6wp3acZxKbcqXPHFSshjLTCgvbbrbDXF+LDPtlAZ /KmBRUb3Y7AzlJSTj+inXOO28Hm/mdXNciNRGDn7+ErqPls2vMXM21zBwLZNUybwxkaU GQPGHEaa0DWALg3OZfG1uaQq0zf33hnhT9AJ4HbElmPeEGksnitxrb5nAGF2JfKay+uC qz6w== X-Gm-Message-State: AHQUAuY4Bxhqsd/oReHf0qL3kqgQZds/qAp0jCAyExfeaCXDO3zVx/4J byDln9xyzTpINVN89Brr0z9hw4ND X-Google-Smtp-Source: AHgI3IakSh10Ojw3PW4bc63dwZtmI6HWx8TIslhY50pLmV8qo+Fp83837+CMqTb9mXhv2n30TYzyYA== X-Received: by 2002:a63:db08:: with SMTP id e8mr34476365pgg.293.1550747863988; Thu, 21 Feb 2019 03:17:43 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id r80sm33297706pfa.111.2019.02.21.03.17.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:43 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:39 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 14/21] diff-parseopt: convert -M|--find-renames Date: Thu, 21 Feb 2019 18:16:14 +0700 Message-Id: <20190221111621.27180-15-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823743 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 D474013A4 for ; Thu, 21 Feb 2019 11:17:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5E313072E for ; Thu, 21 Feb 2019 11:17:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA4B0307C6; Thu, 21 Feb 2019 11:17: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 66E0E3077D for ; Thu, 21 Feb 2019 11:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727547AbfBULRu (ORCPT ); Thu, 21 Feb 2019 06:17:50 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44883 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725891AbfBULRt (ORCPT ); Thu, 21 Feb 2019 06:17:49 -0500 Received: by mail-pl1-f194.google.com with SMTP id c4so8994973pls.11 for ; Thu, 21 Feb 2019 03:17: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=/ANNYIgTQy7D5xyHBis28X+JNmulRc3W33H+PvFRaho=; b=r8nfx0cwuwHBAmg2Rpf7k15HoZkxI6bdtbg8OG/oismbfhQCRqBMuytVmn2Q+YFzxE xhvISs/ow4kYPmgCN4dI9v6mh/i3UzJN4wyR0f9JhNDfj4A9VZH1uRGuFFxifAFpALvB tfYJOcKHiB5CEh86E4NQF5L+wjAJMXEjUeJM+TcvWKLW7bmHWcn3/V4Uj/glUOKc81On F5MXVIKf0CKIi5pDv3tbCRU3YK0rzEz4RvqXh3KWwbKppzz5ibzzvXW6PG7qB+SWMKa7 ojLJm+LsORowekvE+U+6sp57Alz/V8wyExneVofc0JrCOyIfJKyJE0PK/fQEWt07Tep6 naLA== 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=/ANNYIgTQy7D5xyHBis28X+JNmulRc3W33H+PvFRaho=; b=HIBlcrDx3ymgicBy6NxJlpwld/++DkW2hTz97ji/99RayAAKpL1ZkegubTqCY1IxRU LKjIlWosZAPSDpuS7R3OmM+k+j8SNWfmkz4pstSo9SjlitttNZtzedxh+xoUMloaP3kr 916BLYdkaeclyf0pVjO0/eNhmr7uUwpAoF/QYNWgbh2yYdcNeKaVmWtLWuASuD9b/BnC YEwgRiODra26HWGDPhtAd4Jn6CSFY1JxrUMxtN0Vh0A29KBvx/VNchVMXIBLqy3w2nOy cJUn6rEDmrNxz9ayJyUvD/4xOhC5l0/44QT3s18fYjYt3rz7RQioWReZtsXe3tGY0oXZ 2+1Q== X-Gm-Message-State: AHQUAuZePT9Jtrohn3L0N9RslrcRxa1m0mVSKHffKBaEQtjOzFZwSjAU 140Nz+VwZNrgsbbMbt0UlAvUt9Qv X-Google-Smtp-Source: AHgI3IbSLNmJ592T/1m7OE7OURyTpb7awPoZWv/0YheGp51jPJNbNK5haQxbth2vi1l9dEuKBYl/qQ== X-Received: by 2002:a17:902:b590:: with SMTP id a16mr795533pls.22.1550747869166; Thu, 21 Feb 2019 03:17:49 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id c23sm50864996pfe.156.2019.02.21.03.17.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:48 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:44 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 15/21] diff-parseopt: convert -D|--irreversible-delete Date: Thu, 21 Feb 2019 18:16:15 +0700 Message-Id: <20190221111621.27180-16-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823745 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 0D50C13A4 for ; Thu, 21 Feb 2019 11:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0A5330784 for ; Thu, 21 Feb 2019 11:17:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4D28307BF; Thu, 21 Feb 2019 11:17: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 7453A30784 for ; Thu, 21 Feb 2019 11:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727527AbfBULRz (ORCPT ); Thu, 21 Feb 2019 06:17:55 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42005 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbfBULRz (ORCPT ); Thu, 21 Feb 2019 06:17:55 -0500 Received: by mail-pf1-f195.google.com with SMTP id n74so13598424pfi.9 for ; Thu, 21 Feb 2019 03:17: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=d8c8v1eJMeM+oZKZP3OwQM65QTgZ+Ewm3xCsvnVYFPo=; b=qY6g9neVwDvOlvMW0yq6mc5PgZtgMcmqN3ujAA/woXNPB3CSVRGkY2zB0l+jgQeXT3 Fbj+8ku5BZBtbLuB7It/prHiTSQJLY0sTXGOUukkSncF2JcmNFTW6lbtnpvz1DpjAvM7 EVpmY1e30GJUFGeWH1u3MzSk0u6sd7mONQIhbUISMenL478uC7E97I6IlAgjxiK1lOYQ P1rp7mOVFPJ4xdf2YVCRtBZvD6GE8X3w+NPNsRf+6AvY6x1p2eU1Nur7JUUuEKEq6gpb U2I9g8TYzSezwyWhqJ4tDgsv27ID8YT6SASkx2eGKGGGZyy3HTlyAonBfbwP3Gta2Qs0 pJLg== 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=d8c8v1eJMeM+oZKZP3OwQM65QTgZ+Ewm3xCsvnVYFPo=; b=XfiZ2d2yxfADh5KSD3o4qsGKf14GKHGO9jhYuPxBcq996QFDo2VAvEOFa7GUWaiB0u 6nn2sxbasIHNGCCQ6Ntm6+GpZK+UJTjGGhbclGfjXeMeH5Kr2r5vxQag1PhaoagwwtEj NzLmLeQJ6C8RneS7dxd+B9RZMbvnOS5yn+XWYR4vT+PtjRs9+dLuK0j5Sczso7DBhBB+ eFPub8kpg1xMsEfOYaIkf95K00T0O8bn50hhFpcHZmvPlQjI2RUO8gSLRq4srizxmsRo MSuiqBbEiiQhG3J4L6fAA9zX+IdP8l3+xOxYOyGBBQyDE8exovfPgay4wbWJhm0QuHiE vgsA== X-Gm-Message-State: AHQUAuYstlDNHoq6ZdDGqP/hz9ez/96kbPLIQpBUbS4plc7a9yMpEoao eczjhcektLDbU0m5llMsyCD1ePOw X-Google-Smtp-Source: AHgI3IaXxHz6mPhfW07q3Cy6TrUjZF/B+tt1LqDSiKKGjI3Swnea3FNIzCnb5flMT7Mih6m28NwBgA== X-Received: by 2002:a63:112:: with SMTP id 18mr32725826pgb.139.1550747874089; Thu, 21 Feb 2019 03:17:54 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 23sm26992850pft.187.2019.02.21.03.17.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:53 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:49 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 16/21] diff-parseopt: convert -C|--find-copies Date: Thu, 21 Feb 2019 18:16:16 +0700 Message-Id: <20190221111621.27180-17-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823749 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 E199E13A4 for ; Thu, 21 Feb 2019 11:18:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC17930704 for ; Thu, 21 Feb 2019 11:18:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8B14307C3; Thu, 21 Feb 2019 11:18: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 661E53078C for ; Thu, 21 Feb 2019 11:18:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbfBULSA (ORCPT ); Thu, 21 Feb 2019 06:18:00 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38063 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbfBULR7 (ORCPT ); Thu, 21 Feb 2019 06:17:59 -0500 Received: by mail-pl1-f193.google.com with SMTP id e5so14020701plb.5 for ; Thu, 21 Feb 2019 03:17:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PzgSoRaC1NRAN1R0WQUg0Fzdn1CVlCoPCtBlKtDGCkg=; b=Llj3oCnIDeCQ+yWwBpw4uDDDitte4hF12CvXNHLW8SrmYjuanm6WTryUFAtrz48H/i 8qr6sLGvCRaKDkrIwLmjoPvGhaQTPoC7VU8q8pjBQVJM9AYbpLIzDGwWJqSLmAZp4Sqy KSZmWoIOsBpIlj+84dLN8Z0YY/dkVGzqlNxe7AsOz81fDY4DT9VFYTys2VxW1y3pMDuX hVSTzL3NgKac4LdDRrghODCDuCRYKdFWb6Q21cmTPrYuooPbOtdhkcR7EiEvCWJg96ik FSHQ405GHrfdA6Okk7t7KH6vZJMH1irx0QlMEzFvquQhaJjgcD0AJFD9eoeMPTXutM5K F3MA== 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=PzgSoRaC1NRAN1R0WQUg0Fzdn1CVlCoPCtBlKtDGCkg=; b=TTyZtGUJXPYcXopS1Td4JLsp+BHV5SL2dK/ndZFeEO50gEm1XfvZ6kJp5A0T/QVXj1 yV8fzh+qIaBhOEP1L8axmbkI53snPaDtWPtbAlltprbA+oGRWfbUdgqu6TW5vj4YqOse /7K/EqCTG4JPd9QXBXcbKfFuYIJco/MlDIYktbwitdSJ9ZUQNgqVuSgR0RYJtAGWrg1n /UuP8GAqlWoQkF4OBcqxCfNd8WuTB65ZM9RkGEA/h2sPIhIr6XZv0/wyrvRoEggjGLWd FFpSFp77Tk8dZZrjm2/9/a/kUHFtx44oc45opZVckfwwQGe1X5kvhGfMbqTvjQ7SAVU9 u5Yg== X-Gm-Message-State: AHQUAuZuwenyd0PO07PRPPVUflkL0vYy5zLqUzMleQ34zDQG7IKKRX3v EWUHGbq5Y0esPq/XrjVK+VWLNm3V X-Google-Smtp-Source: AHgI3IZND1qwloeh8aN72q4LYl7MWRHcb2ufRN4TiEH5XvtfG2vgRnd+bW9Wg2yIONoNnsbF6aMlfA== X-Received: by 2002:a17:902:7d92:: with SMTP id a18mr25333032plm.215.1550747878930; Thu, 21 Feb 2019 03:17:58 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id y66sm39918537pfy.66.2019.02.21.03.17.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:17:58 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:54 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 17/21] diff-parseopt: convert --find-copies-harder Date: Thu, 21 Feb 2019 18:16:17 +0700 Message-Id: <20190221111621.27180-18-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823751 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 4DF401805 for ; Thu, 21 Feb 2019 11:18:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F27F30784 for ; Thu, 21 Feb 2019 11:18:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33495307D0; Thu, 21 Feb 2019 11:18:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE64630763 for ; Thu, 21 Feb 2019 11:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbfBULSE (ORCPT ); Thu, 21 Feb 2019 06:18:04 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46230 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfBULSE (ORCPT ); Thu, 21 Feb 2019 06:18:04 -0500 Received: by mail-pl1-f195.google.com with SMTP id o6so14021574pls.13 for ; Thu, 21 Feb 2019 03:18:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YwBrKr8tXuuvkt//jokobu5CmCGARO/o27V+S9PMYb0=; b=fM6Ds2EutRKVmFpvpTFuVjrRhmFB7OwZFiiny/tpkPZAcB9yoecv9g1Hie+Q3BNJ/h ZFTsrJTGD6iD6uDg6lPjrNju93xqWhPJp6285++qvVTtI1KHnDKk9aduo6SXN3lLTPY+ lSDUM1s2/82FOC88j+P64aHUkLU/vRFOqoRWe0ev0csrgrfRquyfi1Y7zKuzICZqKZA5 w/HxOCFNt6p2g0QZsR6gBwQw389lRvYy6KCahKM7RTc3s0Lg8gZ7Ba0PiNb3Qr7HCs4W EoCuiK78dVqweUzx1EPImf2uCXgEyr7nczBD0qW96hpV7vBHu0jcIgi7pEWYpWFsKrrj A44A== 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=YwBrKr8tXuuvkt//jokobu5CmCGARO/o27V+S9PMYb0=; b=ruF4PrR6+eek0S4OsrEHUL+kzmnDC+hiiqPRiynRiEoWmRnIDbjisIrq1PUKmMR2wG lopYBnZwKJiaknsCq4YL2rfEKZNGl4zBb4kt3HlJGwBF9AgL3EXoABmRdL4pfk3FIuwg UQw1Q9ie8YYSfoKV5mZzsoy1WjLBbMV1SgBMp6hg4HESCxKahgOv6uAPVnKbKzYYwtIp R5Xd3Eqa95DHfcA1RStDAQwj2we8NGe718GLAX6M8NIGItUSEg+vYUTF2KcPmaVoPGRW MuM0nSCMFv72Qir3sKCaWbBU3ZeFapJg1D/Ebp/3S9tiSSC8XQHwEu5mv9Y7K5PsI/yB Lshg== X-Gm-Message-State: AHQUAuZsHOpk68Q9SCYMDt2q2jmw0HZPBlrV2ndhzgmS2MVG44LWcknF PWxP0BTz3B1GGjHkU+RR2q664sAf X-Google-Smtp-Source: AHgI3IZgFp6lIgGyg5g/pjUhLLk0Osjp7q9AXHSbX+HzPecG1HWTfhszPU1YV5Xb7zwYnpCrFNT34Q== X-Received: by 2002:a17:902:8c95:: with SMTP id t21mr3476270plo.300.1550747883636; Thu, 21 Feb 2019 03:18:03 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id l79sm16146268pfb.102.2019.02.21.03.18.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:18:02 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:17:59 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty Date: Thu, 21 Feb 2019 18:16:18 +0700 Message-Id: <20190221111621.27180-19-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 56b731eae5..915f2fec8b 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 Thu Feb 21 11:16:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823753 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 8AE411805 for ; Thu, 21 Feb 2019 11:18:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79D58283E7 for ; Thu, 21 Feb 2019 11:18:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D0D53057D; Thu, 21 Feb 2019 11:18:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 132F6283E7 for ; Thu, 21 Feb 2019 11:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbfBULSK (ORCPT ); Thu, 21 Feb 2019 06:18:10 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33341 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfBULSJ (ORCPT ); Thu, 21 Feb 2019 06:18:09 -0500 Received: by mail-pf1-f194.google.com with SMTP id i19so586391pfd.0 for ; Thu, 21 Feb 2019 03:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r+IoTu+5nGfYAI5Wxu/4xsWNz0YtQsh3jxogcADZQwU=; b=g+RLRdgmtKKNIvcyrPq+Eo8eGTmo38NXx/rPp/0sT+GsA8LS0MR8pRkJj+9GOL3ARo X/f482DLiLzwgXZqWJTDUHm1amMhy1gyufutmfgEKiZE4Qg9QcTdhj+tc3vIU95NccJI ePlWuHPRsu224oUBxUwwmp7kUmq2q6yCFtZdzxJ6UX7ByGKsCHzQGORMqTkhFKVPVkbj KOuS1syhIIHPkb9bFVxyED8oZv0oBQN6yEnIrHdUSb2vb5iTjLv1U6gM0LkJ3wJcloy7 gJWwQlNmkGAFUa6S1meF3Z0JBElYpqGcE3cMft69mLU3YCHZV2gYDPoFhej9ydeO4REK 8vuQ== 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=r+IoTu+5nGfYAI5Wxu/4xsWNz0YtQsh3jxogcADZQwU=; b=aZVLLWEC9cJmFRCtFFhdZ8mlbln44XTcAf+URUCyHVH+iCDkdHhc+ac554FiMQnoau SPdRVXuj/Nr6NVvJv6DJEJ2tSKCkRzX4UAoa/kCjLKs+jb4JgSTulTI+aRiqeFt/36Mh 9kusQxOCBuPMjthORQfMNCwbDTW8CYACazYm3tTYbfpVFT2iVzlzU6lsjLvaABNEGysP Jf14gUIMn1kugJZDR5WLsT3XLYb32iusoVItRXnN0QKLH57Md9noKm7tWWDL3QISoJz5 VcvX4VrifmuSDuQgpvbcXt0Lox6Oy8E7Q55EV3xfXjbPwFt49tOv3wvEcbRkYz1ywFzC fXqg== X-Gm-Message-State: AHQUAuZf22/ax8lWKIy9Kk/RxU6vfESg4pWKLhJPefRybM1n6LBany0u O4venUqAaDDtQg2ShLi8HciCSTov X-Google-Smtp-Source: AHgI3IZ3wX9A0t8JIodZTe7aZDLaPbhqRnmVyZfg8WJtub8aKioZeXjbd8Xj1kTIChpMBHBHLXo8Jw== X-Received: by 2002:a63:c503:: with SMTP id f3mr33373901pgd.431.1550747888399; Thu, 21 Feb 2019 03:18:08 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id x1sm25290524pge.73.2019.02.21.03.18.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:18:07 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:18:03 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 19/21] diff-parseopt: convert --relative Date: Thu, 21 Feb 2019 18:16:19 +0700 Message-Id: <20190221111621.27180-20-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823755 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 6FF2413A4 for ; Thu, 21 Feb 2019 11:18:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FFB1283E7 for ; Thu, 21 Feb 2019 11:18:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 542973057D; Thu, 21 Feb 2019 11:18:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3A8D303EA for ; Thu, 21 Feb 2019 11:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727657AbfBULSO (ORCPT ); Thu, 21 Feb 2019 06:18:14 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41778 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfBULSO (ORCPT ); Thu, 21 Feb 2019 06:18:14 -0500 Received: by mail-pf1-f196.google.com with SMTP id d25so5251870pfn.8 for ; Thu, 21 Feb 2019 03:18: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=yXHB+MO8nmJb6cofOSQUcGc1JGjBSccypND0xddgwYQ=; b=q1TbA60mYWG+oXurhfhLbcZxzDR0ME2MuXCEZ/zQJIwjkm7+tEn11nEsbcPzFZTTox fTqgKhtrBKdOUnHh4WWUwHJWcyva5oM5Pd84rhVr3A6K+piCmf8wG63ciaUgFK2weYap rQVTjaQNbLrrYnzD5I6OOgfKiVNH7EFe/eZeC0dawH05tOajzMwYH5llncUSvlB1ChFf XOY/H8BQbGi+BKMccIWc4WJB93eG8ccng0H5DDkI7R9E5LsLMU0Lih6KTxSzX3QQA8az q8EiUsMyAjPVOLkPUQTPT5WOHlOZG2aEimQuRfB8MiwBbQfgqypeckkommQOnk+qHLb7 H1Kg== 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=yXHB+MO8nmJb6cofOSQUcGc1JGjBSccypND0xddgwYQ=; b=OhoTYwuAViJlwrYqg+fShagx8iXiOeXC+I1EDdSU+ykz5nnEQrEgtkSdMeEV8C2Vhf 3uEeML/Ly8uMZtUE9P7LDKw28qE1lmR8TQSdCGN0IhTy0FWuaEJW9plxQG+YByOqa/Fj z6ri1SGcmueSuNpUXathyC2T2ODzhuzhgl9xISogAsBXonIIS2SJMz3/vcDdVIyQaRvJ 6xm8IGDHox4PTc8CjOhi1MDY0wtzguwSoDtWHUkStf7tnHzjhFNCDxnvkCNb2Iem/uPy lMjsU0N+oN7yytIT8aPalW6USGcGeP+zNgO38kT68TeZE/nxlUBQ4qWO5Hlhiw+4/AZ9 dMsA== X-Gm-Message-State: AHQUAubjO2VkFC4+P5cR2N9CapGRIcF/u3renathSpF9OItjhljHbrPx iMu56qb0wpCRT6pMMvtcnbyOId6V X-Google-Smtp-Source: AHgI3IbiZXYD8Elh9fQSLRkXF35u0aAX/RpCtQ1AiPauPTYb0qL1mB4JcgI+n5eHWCXjExUOUXi6FA== X-Received: by 2002:a65:6397:: with SMTP id h23mr32859511pgv.347.1550747893317; Thu, 21 Feb 2019 03:18:13 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id e9sm54360468pfb.52.2019.02.21.03.18.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:18:12 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:18:08 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 20/21] diff-parseopt: convert --[no-]minimal Date: Thu, 21 Feb 2019 18:16:20 +0700 Message-Id: <20190221111621.27180-21-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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 Thu Feb 21 11:16:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10823757 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 DBC071805 for ; Thu, 21 Feb 2019 11:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB2373057D for ; Thu, 21 Feb 2019 11:18:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEE1A303EA; Thu, 21 Feb 2019 11:18: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 6149A303EA for ; Thu, 21 Feb 2019 11:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbfBULST (ORCPT ); Thu, 21 Feb 2019 06:18:19 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40351 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbfBULSS (ORCPT ); Thu, 21 Feb 2019 06:18:18 -0500 Received: by mail-pf1-f195.google.com with SMTP id h1so13593720pfo.7 for ; Thu, 21 Feb 2019 03:18: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=Q1STGAwhspv4W/QiXrlxh+NSfu/xQMHcVrif1RNV0oI=; b=i73RCWScYMaSwEtVbMHmdt21IE0bqWoixpvmtelsn5PqfuSwTHfbBYTo+ftSRQyZDb 099UZEZw/qBKA0zjTE3hXerEX7fx+QSVyU2XF2Ei/cU1T3H5KqclSrqUd0V91fz43X7/ 5UgeNKXG19IW3G4o402gqvaZsRNZTLG9EzW7alwMfAOdIjho0ffeq3MdxfXd7b+BXtsP mKlreU3ihz8R5mp5IqtoGu4/KseFz5VwerP+rXD/W7jmBAPUvxJnf0gZ9uEmxlLAVYNU bTQ/AwprrWdV4nmYrptVYUgDimyX6IaeHM7ortaQEk8oHG4IgURw3HRqfkClBF/7NW1u MjoQ== 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=Q1STGAwhspv4W/QiXrlxh+NSfu/xQMHcVrif1RNV0oI=; b=Vb/6Miho23r+PLCBiyYIUCN8PunnQGA62A5urY6EHWFWmG1gowtjvYBKoBz5oAWz9Z iOPjSmfYyw9qQxNVBmrtuz+cKT5JZ/k6SuhLRY1ZbFrI+F6JO6BQpR8OuqhNhE5LbyAX 7MWTMU6wsK69XMb0OX/vE48EW+zXvyb3o5BEowcT0+Rvscoei5L0DVNs9GQ2seG7fHIT WvVZmHqtS2EfNKnlJ353Ygf/oJvg4bhxnwxT1Hw1S7IY0xYWgdbnfE4jISlhYNytnAPh T38B19iE8y3dQztyU4j5GDUWCSVEuDgKjK8myRuKil4hcjuGWWfUJRJ01eY3J2P25CkY RIMw== X-Gm-Message-State: AHQUAuZGUzQCGu2yuA6m6MJ9FSm79LMHD3ftqbNQq+BcxVVGwiDeP8Ca QxYyRtVj+R0qsrIzNbrtrXlhGF5+ X-Google-Smtp-Source: AHgI3IbFyvX/WuPOvhRCG+7SFF5ktYuNZoLbIOtDkCutxU/MbccvVxNdEGTWgVBf2PI2yOBewNI9rA== X-Received: by 2002:a63:c40a:: with SMTP id h10mr34343027pgd.131.1550747898052; Thu, 21 Feb 2019 03:18:18 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id n19sm54659056pfg.67.2019.02.21.03.18.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:18:17 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Thu, 21 Feb 2019 18:18:13 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , rybak.a.v@gmail.com, =?utf-8?b?Tmd1?= =?utf-8?b?eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH v4 21/21] diff-parseopt: convert --ignore-some-changes Date: Thu, 21 Feb 2019 18:16:21 +0700 Message-Id: <20190221111621.27180-22-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190221111621.27180-1-pclouds@gmail.com> References: <20190216113655.25728-1-pclouds@gmail.com> <20190221111621.27180-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);