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

Re: [PATCH v4 2/3] range-diff/format-patch: handle commit ranges other than A..B

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 4, 2021, 21:42 UTC
Message-ID
<nycvar.QRO.7.76.6.2102042027570.54@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqq7dnn7jjz.fsf@gitster.c.googlers.com>
Hi Junio,
On Thu, 4 Feb 2021, Junio C Hamano wrote:
Show 43 quoted lines
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> >  int is_range_diff_range(const char *arg)
> >  {
> > -	return !!strstr(arg, "..");
> > +	char *copy = xstrdup(arg); /* setup_revisions() modifies it */
> > +	const char *argv[] = { "", copy, "--", NULL };
> > +	int i, positive = 0, negative = 0;
> > +	struct rev_info revs;
> > +
> > +	init_revisions(&revs, NULL);
> > +	if (setup_revisions(3, argv, &revs, 0) == 1) {
> > +		for (i = 0; i < revs.pending.nr; i++)
> > +			if (revs.pending.objects[i].item->flags & UNINTERESTING)
> > +				negative++;
> > +			else
> > +				positive++;
> > +	}
> > +
> > +	free(copy);
> > +	object_array_clear(&revs.pending);
> > +	return negative > 0 && positive > 0;
> >  }
>
> One thing that worries me with this code is that I do not see
> anybody that clears UNINTERESTING bit in the flags.  In-core objects
> are singletons, so if a user fed the command two ranges,
>
> 	git range-diff A..B C..A
>
> and this code first handled "A..B", smudging the in-core instance of
> the commit object A with UNINTERESTING bit, that in-core instance
> will be reused when the second range argument "C..A" is given to
> this function again.
>
> At that point, has anybody cleared the UNINTERESTING bit in the
> flags word for the in-core commit A?  I do not see it done in this
> function, but perhaps I am missing it done in the init/setup
> functions (I somehow doubt it, though)?
>
> Shoudn't we be calling clear_commit_marks(ALL_REF_FLAGS) on the
> commits in revs.pending[] array before we clear it?
Yes, we should ;-)
> Depending on the shape of "arg" that is end-user supplied, we may have
> walked the history in handle_dotdot_1() to parse it (e.g. "A...B").

The code in `handle_dotdot_1()` that handles `...` calls `get_merge_bases()`, which eventually calls `get_merge_bases_many_0()` with the `cleanup` parameter set to `1`, i.e. it _does_ clean up the flags.

Otherwise, `git log A...B` couldn't work, could it? ;-)
> Also we'd want to see what needs to be cleared in revs.cmdline
> that would have been populated by calls to add_rev_cmdline().

Is this cleared, like, ever? I don't see any code that handles `cmdline` that way. Seems as we're willfully leaking this.

Ciao, Dscho

Show 23 quoted lines
> Other than that, I quite like the way the actual code turned out to
> be.
>
> > diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
> > index 6eb344be0312..e217cecac9ed 100755
> > --- a/t/t3206-range-diff.sh
> > +++ b/t/t3206-range-diff.sh
> > @@ -150,6 +150,14 @@ test_expect_success 'simple A B C (unmodified)' '
> >  	test_cmp expect actual
> >  '
> >
> > +test_expect_success 'A^! and A^-<n> (unmodified)' '
> > +	git range-diff --no-color topic^! unmodified^-1 >actual &&
> > +	cat >expect <<-EOF &&
> > +	1:  $(test_oid t4) = 1:  $(test_oid u4) s/12/B/
> > +	EOF
> > +	test_cmp expect actual
> > +'
> > +
> >  test_expect_success 'trivial reordering' '
> >  	git range-diff --no-color master topic reordered >actual &&
> >  	cat >expect <<-EOF &&
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 45 of 63 in “Range diff with ranges lacking dotdot”
  1. 0/3 Range diff with ranges lacking dotdotJohannes Schindelin via GitGitGadget, Jan 21, 2021
  2. 1/3 range-diff: refactor check for commit rangeJohannes Schindelin via GitGitGadget, Jan 21, 2021
  3. Junio C HamanoJan 21, 2021
  4. Phillip WoodJan 22, 2021
  5. Junio C HamanoJan 22, 2021
  6. Phillip WoodJan 23, 2021
  7. Johannes SchindelinJan 26, 2021
  8. 2/3 range-diff: handle commit ranges other than A..BJohannes Schindelin via GitGitGadget, Jan 21, 2021
  9. Eric SunshineJan 21, 2021
  10. Johannes SchindelinJan 22, 2021
  11. Junio C HamanoJan 21, 2021
  12. Johannes SchindelinJan 22, 2021
  13. 3/3 range-diff(docs): explain how to specify commit rangesJohannes Schindelin via GitGitGadget, Jan 21, 2021
  14. Junio C HamanoJan 21, 2021
  15. Johannes SchindelinJan 22, 2021
  16. Junio C HamanoJan 22, 2021
  17. Johannes SchindelinJan 27, 2021
  18. Junio C HamanoJan 28, 2021
  19. Uwe Kleine-KönigJan 22, 2021
  20. Johannes SchindelinJan 26, 2021
  21. Uwe Kleine-KönigJan 22, 2021
  22. 0/3 Range diff with ranges lacking dotdotJohannes Schindelin via GitGitGadget, Jan 22, 2021
  23. 2/3 range-diff/format-patch: handle commit ranges other than A..BJohannes Schindelin via GitGitGadget, Jan 22, 2021
  24. Junio C HamanoJan 22, 2021
  25. Johannes SchindelinJan 27, 2021
  26. Junio C HamanoJan 28, 2021
  27. Johannes SchindelinJan 28, 2021
  28. 3/3 range-diff(docs): explain how to specify commit rangesJohannes Schindelin via GitGitGadget, Jan 22, 2021
  29. 1/3 range-diff/format-patch: refactor check for commit rangeJohannes Schindelin via GitGitGadget, Jan 22, 2021
  30. Junio C HamanoJan 22, 2021
  31. Uwe Kleine-KönigJan 25, 2021
  32. Junio C HamanoJan 25, 2021
  33. Uwe Kleine-KönigJan 25, 2021
  34. Junio C HamanoJan 26, 2021
  35. 0/3 Range diff with ranges lacking dotdotJohannes Schindelin via GitGitGadget, Jan 27, 2021
  36. 3/3 range-diff(docs): explain how to specify commit rangesJohannes Schindelin via GitGitGadget, Jan 27, 2021
  37. 2/3 range-diff/format-patch: handle commit ranges other than A..BJohannes Schindelin via GitGitGadget, Jan 27, 2021
  38. 1/3 range-diff/format-patch: refactor check for commit rangeJohannes Schindelin via GitGitGadget, Jan 27, 2021
  39. 0/3 Range diff with ranges lacking dotdotJohannes Schindelin via GitGitGadget, Feb 4, 2021
  40. 1/3 range-diff/format-patch: refactor check for commit rangeJohannes Schindelin via GitGitGadget, Feb 4, 2021
  41. Junio C HamanoFeb 4, 2021
  42. Johannes SchindelinFeb 4, 2021
  43. 2/3 range-diff/format-patch: handle commit ranges other than A..BJohannes Schindelin via GitGitGadget, Feb 4, 2021
  44. Junio C HamanoFeb 4, 2021
  45. Johannes SchindelinFeb 4, 2021
  46. Junio C HamanoFeb 4, 2021
  47. Johannes SchindelinFeb 4, 2021
  48. 3/3 range-diff(docs): explain how to specify commit rangesJohannes Schindelin via GitGitGadget, Feb 4, 2021
  49. Junio C HamanoFeb 4, 2021
  50. Johannes SchindelinFeb 4, 2021
  51. Junio C HamanoFeb 4, 2021
  52. 0/3 Range diff with ranges lacking dotdotJohannes Schindelin via GitGitGadget, Feb 4, 2021
  53. 3/3 range-diff(docs): explain how to specify commit rangesJohannes Schindelin via GitGitGadget, Feb 4, 2021
  54. 1/3 range-diff/format-patch: refactor check for commit rangeJohannes Schindelin via GitGitGadget, Feb 4, 2021
  55. 2/3 range-diff/format-patch: handle commit ranges other than A..BJohannes Schindelin via GitGitGadget, Feb 4, 2021
  56. Junio C HamanoFeb 5, 2021
  57. Junio C HamanoFeb 5, 2021
  58. Johannes SchindelinFeb 5, 2021
  59. 0/3 Range diff with ranges lacking dotdotJohannes Schindelin via GitGitGadget, Feb 5, 2021
  60. 2/3 range-diff/format-patch: handle commit ranges other than A..BJohannes Schindelin via GitGitGadget, Feb 5, 2021
  61. 3/3 range-diff(docs): explain how to specify commit rangesJohannes Schindelin via GitGitGadget, Feb 5, 2021
  62. 1/3 range-diff/format-patch: refactor check for commit rangeJohannes Schindelin via GitGitGadget, Feb 5, 2021
  63. Johannes SchindelinFeb 6, 2021

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.