git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Lucas De Marchi <lucas.demarchi@intel.com>,
	Stefan Beller <sbeller@google.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v2] range-diff: add a --no-patch option to show a summary
Date: Wed, 07 Nov 2018 09:57:54 +0900	[thread overview]
Message-ID: <xmqqsh0dd7ql.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20181106162413.9785-1-avarab@gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Tue, 6 Nov 2018 16:24:13 +0000")

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> diff --git a/builtin/range-diff.c b/builtin/range-diff.c
> index f01a0be851..05d1f6b6b6 100644
> --- a/builtin/range-diff.c
> +++ b/builtin/range-diff.c
> @@ -16,11 +16,14 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
>  	int creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
>  	struct diff_options diffopt = { NULL };
>  	int simple_color = -1;
> +	int no_patch = 0;
>  	struct option options[] = {
>  		OPT_INTEGER(0, "creation-factor", &creation_factor,
>  			    N_("Percentage by which creation is weighted")),
>  		OPT_BOOL(0, "no-dual-color", &simple_color,
>  			    N_("use simple diff colors")),
> +		OPT_BOOL_F('s', "no-patch", &no_patch,
> +			 N_("show patch output"), PARSE_OPT_NONEG),

As OPT_BOOL("patch") natively takes "--no-patch" to flip the bool
off, an int variable "patch" that is initialized to 1 would make it
more readable by avoiding double negation !no_patch like the one we
see below.  I guess the reason behind the contortion you wanted to
give the synonym --silent to it?

> @@ -92,7 +95,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
>  	}
>  
>  	res = show_range_diff(range1.buf, range2.buf, creation_factor,
> -			      simple_color < 1, &diffopt);
> +			      simple_color < 1, !no_patch, &diffopt);

>  	strbuf_release(&range1);
>  	strbuf_release(&range2);

> @@ -7,6 +7,7 @@
>  
>  int show_range_diff(const char *range1, const char *range2,
>  		    int creation_factor, int dual_color,
> +		    int patch,
>  		    struct diff_options *diffopt);

Other than that small "Huh?", the code looks good to me.

> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
> index 6aae364171..27e071650b 100755
> --- a/t/t3206-range-diff.sh
> +++ b/t/t3206-range-diff.sh
> @@ -122,6 +122,26 @@ test_expect_success 'changed commit' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'changed commit -p & --patch' '
> +	git range-diff --no-color -p topic...changed >actual &&
> +	test_cmp expected actual &&
> +	git range-diff --no-color --patch topic...changed >actual &&
> +	test_cmp expected actual

This makes sure that -p and --patch produces the same output as the
default case?  I am not sure who in the parseopt API groks the
single letter "-p" in this case offhand.  Care to explain how?

The other side of the test to see -s/--no-patch we see below also
makes sense.

> +test_expect_success 'changed commit -s & --no-patch' '
> +...
> +	cat >expected <<-EOF &&

Quote EOF to allow readers skim the contents without looking for and
worrying about $substitutions in there, unless there are tons of
offending code in the same script already in which case we should
leave the clean-up outside this primary change.


  reply	other threads:[~2018-11-07  0:58 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05 20:06 [PATCH] range-diff: add a --no-patch option to show a summary Ævar Arnfjörð Bjarmason
2018-11-05 20:26 ` Eric Sunshine
2018-11-05 21:00   ` Ævar Arnfjörð Bjarmason
2018-11-06 10:43     ` Johannes Schindelin
2018-11-06 16:01       ` Ævar Arnfjörð Bjarmason
2018-11-07 10:34         ` Johannes Schindelin
2018-11-07 10:43           ` Johannes Schindelin
2018-11-07 10:55             ` Johannes Schindelin
2018-11-07 11:08               ` Johannes Schindelin
2018-11-07 12:22                 ` [PATCH v3 0/2] range-diff: doc + regression fix Ævar Arnfjörð Bjarmason
2018-11-07 12:22                 ` [PATCH v3 1/2] range-diff doc: add a section about output stability Ævar Arnfjörð Bjarmason
2018-11-07 13:10                   ` Stephen & Linda Smith
2018-11-07 22:52                     ` Junio C Hamano
2018-11-07 19:06                   ` Martin Ågren
2018-11-07 12:22                 ` [PATCH v3 2/2] range-diff: fix regression in passing along diff options Ævar Arnfjörð Bjarmason
2018-11-08 17:08                   ` Eric Sunshine
2018-11-08 22:34                     ` Ævar Arnfjörð Bjarmason
2018-11-09  6:46                       ` Eric Sunshine
2018-11-09  7:36                         ` Ævar Arnfjörð Bjarmason
2018-11-09 10:18                   ` [PATCH v4 0/3] range-diff fixes Ævar Arnfjörð Bjarmason
2018-11-09 16:32                     ` Johannes Schindelin
2018-11-09 10:18                   ` [PATCH v4 1/3] range-diff doc: add a section about output stability Ævar Arnfjörð Bjarmason
2018-11-09 10:18                   ` [PATCH v4 2/3] range-diff: fix regression in passing along diff options Ævar Arnfjörð Bjarmason
2018-11-09 10:18                   ` [PATCH v4 3/3] range-diff: make diff option behavior (e.g. --stat) consistent Ævar Arnfjörð Bjarmason
2018-11-09 13:25                     ` Stephen & Linda Smith
2018-11-11  8:43                     ` Eric Sunshine
2018-11-12  3:17                       ` Junio C Hamano
2018-11-12  3:32                     ` Junio C Hamano
2018-11-13 18:55                       ` [PATCH v5 0/3] range-diff fixes Ævar Arnfjörð Bjarmason
2018-11-14 15:36                         ` Johannes Schindelin
2018-11-13 18:55                       ` [PATCH v5 1/3] range-diff doc: add a section about output stability Ævar Arnfjörð Bjarmason
2018-11-13 18:55                       ` [PATCH v5 2/3] range-diff: fix regression in passing along diff options Ævar Arnfjörð Bjarmason
2018-11-13 18:55                       ` [PATCH v5 3/3] range-diff: make diff option behavior (e.g. --stat) consistent Ævar Arnfjörð Bjarmason
2018-11-06  4:16 ` [PATCH] range-diff: add a --no-patch option to show a summary Junio C Hamano
2018-11-06  5:15   ` Eric Sunshine
2018-11-06  5:57     ` Junio C Hamano
2018-11-06  8:36     ` Ævar Arnfjörð Bjarmason
2018-11-06 16:24 ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2018-11-07  0:57   ` Junio C Hamano [this message]
2018-11-07 11:11     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsh0dd7ql.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=lucas.demarchi@intel.com \
    --cc=sbeller@google.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).