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

Re: Regression in v2.23

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 8, 2019, 07:43 UTC
Message-ID
<nycvar.QRO.7.76.6.1910080943100.46@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqqh84knd7l.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Tue, 8 Oct 2019, Junio C Hamano wrote:
Show 30 quoted lines
> Thomas Gummerer <t.gummerer@gmail.com> writes:
>
> > We can however rely on 'patch.def_name' in that case, which is
> > extracted from the 'diff --git' line and should be equal to
> > 'patch.new_name'.  Use that instead to avoid the segfault.
>
> This patch makes the way this function calls parse_git_diff_header()
> more in line with the way how it is used by its original caller in
> apply.c::find_header(), but not quite.
>
> I have to wonder if we want to move a bit of code around so that
> callers of parse_git_diff_header() do not have to worry about
> def_name and can rely on new_name and old_name fields correctly
> filled.
>
> There was only one caller of the parse_git_diff_header() function
> before range-diff.  The division of labour between find_header() and
> parse_git_diff_header() did not make any difference to the consumers
> of the new/old_name fields.  They only cared that they do not have
> to worry about def_name.  But by calling parse_git_diff_header()
> that forces the caller to worry about def_name (which is done by
> find_header() to free its callers from doing so), range-diff took
> responsibility of caring, which was suboptimal.  The interface could
> have been a bit more cleaned up before we started to reuse it in the
> new caller, and as this bug shows, it may be time to do so now, no?
>
> Perhaps before returing, parse_git_diff_header() should fill the two
> names with xstrdup() of def_name if (!old_name && !new_name &&
> !!def_name); all other cases the existing caller and this new caller
> would work unchanged correctly, no?
FWIW I totally agree.

Ciao, Dscho

Previous: Junio C HamanoNext: Uwe Kleine-König
Message 4 of 10 in “Regression in v2.23”
  1. Uwe Kleine-KönigOct 7, 2019
  2. Thomas GummererOct 7, 2019
  3. Junio C HamanoOct 8, 2019
  4. Johannes SchindelinOct 8, 2019
  5. Uwe Kleine-KönigOct 8, 2019
  6. Johannes SchindelinOct 8, 2019
  7. Johannes SchindelinOct 8, 2019
  8. range-diff: don't segfault with mode-only changesThomas Gummerer, Oct 8, 2019
  9. Johannes SchindelinOct 8, 2019
  10. Uwe Kleine-KönigOct 9, 2019

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.