git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] range-diff: add a --no-patch option to show a summary

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 7, 2018, 00:57 UTC
Message-ID
<xmqqsh0dd7ql.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20181106162413.9785-1-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 16 quoted lines
> 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?

Show 6 quoted lines
> @@ -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);
Show 6 quoted lines
> @@ -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.
Show 13 quoted lines
> 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.

Previous: Ævar Arnfjörð BjarmasonNext: Johannes Schindelin
Message 39 of 40 in “range-diff: add a --no-patch option to show a summary”
  1. range-diff: add a --no-patch option to show a summaryÆvar Arnfjörð Bjarmason, Nov 5, 2018
  2. Eric SunshineNov 5, 2018
  3. Ævar Arnfjörð BjarmasonNov 5, 2018
  4. Johannes SchindelinNov 6, 2018
  5. Ævar Arnfjörð BjarmasonNov 6, 2018
  6. Johannes SchindelinNov 7, 2018
  7. Johannes SchindelinNov 7, 2018
  8. Johannes SchindelinNov 7, 2018
  9. Johannes SchindelinNov 7, 2018
  10. 0/2 range-diff: doc + regression fixÆvar Arnfjörð Bjarmason, Nov 7, 2018
  11. 1/2 range-diff doc: add a section about output stabilityÆvar Arnfjörð Bjarmason, Nov 7, 2018
  12. Stephen & Linda SmithNov 7, 2018
  13. Junio C HamanoNov 7, 2018
  14. Martin ÅgrenNov 7, 2018
  15. 2/2 range-diff: fix regression in passing along diff optionsÆvar Arnfjörð Bjarmason, Nov 7, 2018
  16. Eric SunshineNov 8, 2018
  17. Ævar Arnfjörð BjarmasonNov 8, 2018
  18. Eric SunshineNov 9, 2018
  19. Ævar Arnfjörð BjarmasonNov 9, 2018
  20. 0/3 range-diff fixesÆvar Arnfjörð Bjarmason, Nov 9, 2018
  21. Johannes SchindelinNov 9, 2018
  22. 1/3 range-diff doc: add a section about output stabilityÆvar Arnfjörð Bjarmason, Nov 9, 2018
  23. 2/3 range-diff: fix regression in passing along diff optionsÆvar Arnfjörð Bjarmason, Nov 9, 2018
  24. 3/3 range-diff: make diff option behavior (e.g. --stat) consistentÆvar Arnfjörð Bjarmason, Nov 9, 2018
  25. Stephen & Linda SmithNov 9, 2018
  26. Eric SunshineNov 11, 2018
  27. Junio C HamanoNov 12, 2018
  28. Junio C HamanoNov 12, 2018
  29. 0/3 range-diff fixesÆvar Arnfjörð Bjarmason, Nov 13, 2018
  30. Johannes SchindelinNov 14, 2018
  31. 1/3 range-diff doc: add a section about output stabilityÆvar Arnfjörð Bjarmason, Nov 13, 2018
  32. 2/3 range-diff: fix regression in passing along diff optionsÆvar Arnfjörð Bjarmason, Nov 13, 2018
  33. 3/3 range-diff: make diff option behavior (e.g. --stat) consistentÆvar Arnfjörð Bjarmason, Nov 13, 2018
  34. Junio C HamanoNov 6, 2018
  35. Eric SunshineNov 6, 2018
  36. Junio C HamanoNov 6, 2018
  37. Ævar Arnfjörð BjarmasonNov 6, 2018
  38. range-diff: add a --no-patch option to show a summaryÆvar Arnfjörð Bjarmason, Nov 6, 2018
  39. Junio C HamanoNov 7, 2018
  40. Johannes SchindelinNov 7, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.