<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/diff.c, branch v2.40.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.40.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.40.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-02-27T18:08:56Z</updated>
<entry>
<title>Merge branch 'jc/diff-algo-attribute'</title>
<updated>2023-02-27T18:08:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-02-27T18:08:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ece8dc97ae53d08247aa283b6f299e3e5b2669db'/>
<id>urn:sha1:ece8dc97ae53d08247aa283b6f299e3e5b2669db</id>
<content type='text'>
The "diff" drivers specified by the "diff" attribute attached to
paths can now specify which algorithm (e.g. histogram) to use.

* jc/diff-algo-attribute:
  diff: teach diff to read algorithm from diff driver
  diff: consolidate diff algorithm option parsing
</content>
</entry>
<entry>
<title>diff: teach diff to read algorithm from diff driver</title>
<updated>2023-02-21T17:29:10Z</updated>
<author>
<name>John Cai</name>
<email>johncai86@gmail.com</email>
</author>
<published>2023-02-20T21:04:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a4cf900ee734ce9bb73d57c5dfbb1da4a5a88bd3'/>
<id>urn:sha1:a4cf900ee734ce9bb73d57c5dfbb1da4a5a88bd3</id>
<content type='text'>
It can be useful to specify diff algorithms per file type. For example,
one may want to use the minimal diff algorithm for .json files, another
for .c files, etc.

The diff machinery already checks attributes for a diff driver. Teach
the diff driver parser a new type "algorithm" to look for in the
config, which will be used if a driver has been specified through the
attributes.

Enforce precedence of the diff algorithm by favoring the command line
option, then looking at the driver attributes &amp; config combination, then
finally the diff.algorithm config.

To enforce precedence order, use a new `ignore_driver_algorithm` member
during options parsing to indicate the diff algorithm was set via command
line args.

Signed-off-by: John Cai &lt;johncai86@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff: consolidate diff algorithm option parsing</title>
<updated>2023-02-21T17:29:08Z</updated>
<author>
<name>John Cai</name>
<email>johncai86@gmail.com</email>
</author>
<published>2023-02-20T21:04:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=11e95e16e8ef70c6c757d50a99f9b310e6c795f4'/>
<id>urn:sha1:11e95e16e8ef70c6c757d50a99f9b310e6c795f4</id>
<content type='text'>
A subsequent commit will need the ability to tell if the diff algorithm
was set through the command line through setting a new member of
diff_options. While this logic can be added to the
diff_opt_diff_algorithm() callback, the `--minimal` and `--histogram`
options are handled via OPT_BIT without a callback.

Remedy this by consolidating the options parsing logic for --minimal and
--histogram into one callback. This way we can modify `diff_options` in
that function.

As an additional refactor, the logic that sets the diff algorithm in
diff_opt_diff_algorithm() can be refactored into a helper that will
allow multiple callsites to set the diff algorithm.

Signed-off-by: John Cai &lt;johncai86@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/ext-diff-with-relative'</title>
<updated>2023-01-16T20:07:46Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-01-16T20:07:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1120c54c12788c232d96702702e719f72e7ece14'/>
<id>urn:sha1:1120c54c12788c232d96702702e719f72e7ece14</id>
<content type='text'>
"git diff --relative" did not mix well with "git diff --ext-diff",
which has been corrected.

* jk/ext-diff-with-relative:
  diff: drop "name" parameter from prepare_temp_file()
  diff: clean up external-diff argv setup
  diff: use filespec path to set up tempfiles for ext-diff
</content>
</entry>
<entry>
<title>diff: drop "name" parameter from prepare_temp_file()</title>
<updated>2023-01-06T12:50:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2023-01-06T11:05:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f034bb1cad862a678030cdf0ae833636f9d7dbca'/>
<id>urn:sha1:f034bb1cad862a678030cdf0ae833636f9d7dbca</id>
<content type='text'>
The prepare_temp_file() function takes a diff_filespec as well as a
filename. But it is almost certainly an error to pass in a name that
isn't the filespec's "path" parameter, since that is the only thing that
reliably tells us how to find the content (and indeed, this was the
source of a recently-fixed bug).

So let's drop the redundant "name" parameter and just use one-&gt;path
throughout the function. This simplifies the interface a little bit, and
makes it impossible for calling code to get it wrong.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff: clean up external-diff argv setup</title>
<updated>2023-01-06T12:50:07Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2023-01-06T11:04:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=de8f14e1c01451e751da80fb6309bf4a371b5b2b'/>
<id>urn:sha1:de8f14e1c01451e751da80fb6309bf4a371b5b2b</id>
<content type='text'>
Since the previous commit, setting up the tempfile for an external diff
uses df-&gt;path from the diff_filespec, rather than the logical name. This
means add_external_diff_name() does not need to take a "name" parameter
at all, and we can drop it. And that in turn lets us simplify the
conditional for handling renames (when the "other" name is non-NULL).

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff: use filespec path to set up tempfiles for ext-diff</title>
<updated>2023-01-06T12:49:55Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2023-01-06T11:03:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a0f83e777660dbf7d9526c05d94fc920e459aed9'/>
<id>urn:sha1:a0f83e777660dbf7d9526c05d94fc920e459aed9</id>
<content type='text'>
When we're going to run an external diff, we have to make the contents
of the pre- and post-images available either by dumping them to a
tempfile, or by pointing at a valid file in the worktree. The logic of
this is all handled by prepare_temp_file(), and we just pass in the
filename and the diff_filespec.

But there's a gotcha here. The "filename" we have is a logical filename
and not necessarily a path on disk or in the repository. This matters in
at least one case: when using "--relative", we may have a name like
"foo", even though the file content is found at "subdir/foo". As a
result, we look for the wrong path, fail to find "foo", and claim that
the file has been deleted (passing "/dev/null" to the external diff,
rather than the correct worktree path).

We can fix this by passing the pathname from the diff_filespec, which
should always be a full repository path (and that's what we want even if
reusing a worktree file, since we're always operating from the top-level
of the working tree).

The breakage seems to go all the way back to cd676a5136 (diff
--relative: output paths as relative to the current subdirectory,
2008-02-12). As far as I can tell, before then "name" would always have
been the same as the filespec's "path".

There are two related cases I looked at that aren't buggy:

  1. the only other caller of prepare_temp_file() is run_textconv(). But
     it always passes the filespec's path field, so it's OK.

  2. I wondered if file renames/copies might cause similar confusion.
     But they don't, because run_external_diff() receives two names in
     that case: "name" and "other", which correspond to the two sides of
     the diff. And we did correctly pass "other" when handling the
     post-image side. Barring the use of "--relative", that would always
     match "two-&gt;path", the path of the second filespec (and the rename
     destination).

So the only bug is just the interaction with external diff drivers and
--relative.

Reported-by: Carl Baldwin &lt;carl@ecbaldwin.net&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'pg/diff-stat-unmerged-regression-fix'</title>
<updated>2022-12-26T02:42:07Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-12-26T02:42:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e57caee004362ee855a3bc8fc826abe251eb64f8'/>
<id>urn:sha1:e57caee004362ee855a3bc8fc826abe251eb64f8</id>
<content type='text'>
The output from "git diff --stat" on an unmerged path lost the
terminating LF in Git 2.39, which has been corrected.

* pg/diff-stat-unmerged-regression-fix:
  diff: fix regression with --stat and unmerged file
</content>
</entry>
<entry>
<title>Merge branch 'jk/unused-post-2.39'</title>
<updated>2022-12-26T02:42:05Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-12-26T02:42:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=179547932fb8484a5ab532ef1b56ed8b01946ab5'/>
<id>urn:sha1:179547932fb8484a5ab532ef1b56ed8b01946ab5</id>
<content type='text'>
Code clean-up around unused function parameters.

* jk/unused-post-2.39:
  userdiff: mark unused parameter in internal callback
  list-objects-filter: mark unused parameters in virtual functions
  diff: mark unused parameters in callbacks
  xdiff: mark unused parameter in xdl_call_hunk_func()
  xdiff: drop unused parameter in def_ff()
  ws: drop unused parameter from ws_blank_line()
  list-objects: drop process_gitlink() function
  blob: drop unused parts of parse_blob_buffer()
  ls-refs: use repository parameter to iterate refs
</content>
</entry>
<entry>
<title>Merge branch 'rs/diff-parseopts'</title>
<updated>2022-12-19T02:46:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-12-19T02:46:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ab91f6b7c42531406bcca0e48c48530126332142'/>
<id>urn:sha1:ab91f6b7c42531406bcca0e48c48530126332142</id>
<content type='text'>
The way the diff machinery prepares the options array for the
parse_options API has been refactored to avoid resource leaks.

* rs/diff-parseopts:
  diff: remove parseopts member from struct diff_options
  diff: use add_diff_options() in diff_opt_parse()
  diff: factor out add_diff_options()
</content>
</entry>
</feed>
