<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/diff.c, branch v2.47.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.47.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.47.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-11-25T03:29:39Z</updated>
<entry>
<title>Merge branch 'jk/output-prefix-cleanup' into maint-2.47</title>
<updated>2024-11-25T03:29:39Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-11-25T03:29:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6b03fd8dcd1fd88ad834a3b3f678631d6d68ea54'/>
<id>urn:sha1:6b03fd8dcd1fd88ad834a3b3f678631d6d68ea54</id>
<content type='text'>
Code clean-up.

* jk/output-prefix-cleanup:
  diff: store graph prefix buf in git_graph struct
  diff: return line_prefix directly when possible
  diff: return const char from output_prefix callback
  diff: drop line_prefix_length field
  line-log: use diff_line_prefix() instead of custom helper
</content>
</entry>
<entry>
<title>diff: return const char from output_prefix callback</title>
<updated>2024-10-03T21:22:22Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-10-03T21:09:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=436728fe9d75d05fa2439f867ca2039012b86e69'/>
<id>urn:sha1:436728fe9d75d05fa2439f867ca2039012b86e69</id>
<content type='text'>
The diff_options structure has an output_prefix callback for returning a
prefix string, but it does so by returning a pointer to a strbuf.

This makes the interface awkward. There's no reason the callback should
need to use a strbuf, and it creates questions about whether the
ownership of the resulting buffer should be transferred to the caller
(it should not be, but a recent attempt to clean up this code led to a
double-free in some cases).

The one advantage we get is that the strbuf contains a ptr/len pair, so
we could in theory have a prefix with embedded NULs. But we can observe
that none of the existing callbacks would ever produce such a NUL (they
are usually just indentation or graph symbols, and even the
"--line-prefix" option takes a NUL-terminated string).

And anyway, only one caller (the one in log_tree_diff_flush) actually
looks at the strbuf length. In every other case we use a helper function
which discards the length and just returns the NUL-terminated string.

So let's just have the callback return a "const char *" pointer. It's up
to the callbacks themselves if they want to use a strbuf under the hood.
And now the caller in log_tree_diff_flush() can just use the helper
function along with everybody else. That lets us even simplify out the
function pointer check, since the helper returns an empty string
(technically this does mean we'll sometimes issue an empty fputs() call,
but I don't think this code path is hot enough to care about that).

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: drop line_prefix_length field</title>
<updated>2024-10-03T21:22:21Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-10-03T21:06:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2011bb4f34d773a7de2d64769ca9f508feba8089'/>
<id>urn:sha1:2011bb4f34d773a7de2d64769ca9f508feba8089</id>
<content type='text'>
The diff_options structure holds a line_prefix string and an associated
length. But the length is always just the strlen() of the NUL-terminated
string. Let's simplify the code by just storing the string pointer and
assuming it is NUL-terminated when we use it.

This will cause us to compute the string length in a few extra spots,
but I don't think any of these are particularly hot code paths.

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 'ps/leakfixes-part-7'</title>
<updated>2024-10-02T14:46:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-10-02T14:46:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=365529e1ea19b44a7a253b780f3ae3a1cb2f081f'/>
<id>urn:sha1:365529e1ea19b44a7a253b780f3ae3a1cb2f081f</id>
<content type='text'>
More leak-fixes.

* ps/leakfixes-part-7: (23 commits)
  diffcore-break: fix leaking filespecs when merging broken pairs
  revision: fix leaking parents when simplifying commits
  builtin/maintenance: fix leak in `get_schedule_cmd()`
  builtin/maintenance: fix leaking config string
  promisor-remote: fix leaking partial clone filter
  grep: fix leaking grep pattern
  submodule: fix leaking submodule ODB paths
  trace2: destroy context stored in thread-local storage
  builtin/difftool: plug several trivial memory leaks
  builtin/repack: fix leaking configuration
  diffcore-order: fix leaking buffer when parsing orderfiles
  parse-options: free previous value of `OPTION_FILENAME`
  diff: fix leaking orderfile option
  builtin/pull: fix leaking "ff" option
  dir: fix off by one errors for ignored and untracked entries
  builtin/submodule--helper: fix leaking remote ref on errors
  t/helper: fix leaking subrepo in nested submodule config helper
  builtin/submodule--helper: fix leaking error buffer
  builtin/submodule--helper: clear child process when not running it
  submodule: fix leaking update strategy
  ...
</content>
</entry>
<entry>
<title>diff: fix leaking orderfile option</title>
<updated>2024-09-27T15:25:35Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-09-26T11:46:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=76c7e708bbd6b19856d1ffa58f720e8da0c9eb0f'/>
<id>urn:sha1:76c7e708bbd6b19856d1ffa58f720e8da0c9eb0f</id>
<content type='text'>
The `orderfile` diff option is being assigned via `OPT_FILENAME()`,
which assigns an allocated string to the variable. We never free it
though, causing a memory leak.

Change the type of the string to `char *` and free it to plug the leak.
This also requires us to use `xstrdup()` to assign the global config to
it in case it is set.

This leak is being hit in t7621, but plugging it alone does not make the
test suite pass.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/diff-exit-code-binary'</title>
<updated>2024-09-26T01:24:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-09-26T01:24:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f92c61aef0190641e01294dad3b891b28113e1d5'/>
<id>urn:sha1:f92c61aef0190641e01294dad3b891b28113e1d5</id>
<content type='text'>
"git diff --exit-code" ignored modified binary files, which has
been corrected.

* rs/diff-exit-code-binary:
  diff: report modified binary files as changes in builtin_diff()
</content>
</entry>
<entry>
<title>diff: report modified binary files as changes in builtin_diff()</title>
<updated>2024-09-23T16:41:07Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-09-21T15:09:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9a41735af66dba1b677a8e88e7c2bc2f831bf6d2'/>
<id>urn:sha1:9a41735af66dba1b677a8e88e7c2bc2f831bf6d2</id>
<content type='text'>
The diff machinery has two ways to detect changes to set the exit code:
Just comparing hashes and comparing blob contents.  The latter is needed
if certain changes have to be ignored, e.g. with --ignore-space-change
or --ignore-matching-lines.  It's enabled by the diff_options flag
diff_from_contents.

The code for handling binary files added by 1aaf69e669 (diff: shortcut
for diff'ing two binary SHA-1 objects, 2014-08-16) always uses a quick
hash-only comparison, even if the slow way is taken.  We need it to
report a hash difference as a change for the purpose of setting the
exit code, though, but it never did.  Fix that.

d7b97b7185 (diff: let external diffs report that changes are
uninteresting, 2024-06-09) set diff_from_contents if external diff
programs are allowed.  This is the default e.g. for git diff, and so
that change exposed the inconsistency much more widely.

Reported-by: Kohei Shibata &lt;shiba200712@gmail.com&gt;
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jc/range-diff-lazy-setup'</title>
<updated>2024-09-16T21:22:55Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-09-16T21:22:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=be8ca2848a9e73f6ddc31ebce2ddc3c367d4f0cb'/>
<id>urn:sha1:be8ca2848a9e73f6ddc31ebce2ddc3c367d4f0cb</id>
<content type='text'>
Code clean-up.

* jc/range-diff-lazy-setup:
  remerge-diff: clean up temporary objdir at a central place
  remerge-diff: lazily prepare temporary objdir on demand
</content>
</entry>
<entry>
<title>Merge branch 'rs/diff-exit-code-fix'</title>
<updated>2024-09-13T22:27:43Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-09-13T22:27:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41390eb3e6411925365a4932ca4b5c12e609c779'/>
<id>urn:sha1:41390eb3e6411925365a4932ca4b5c12e609c779</id>
<content type='text'>
In a few corner cases "git diff --exit-code" failed to report
"changes" (e.g., renamed without any content change), which has
been corrected.

* rs/diff-exit-code-fix:
  diff: report dirty submodules as changes in builtin_diff()
  diff: report copies and renames as changes in run_diff_cmd()
</content>
</entry>
<entry>
<title>diff: report dirty submodules as changes in builtin_diff()</title>
<updated>2024-09-08T20:21:24Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-09-08T07:08:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=11591850ddd5e65d3d0aab22c0a7131b1eb1d6f0'/>
<id>urn:sha1:11591850ddd5e65d3d0aab22c0a7131b1eb1d6f0</id>
<content type='text'>
The diff machinery has two ways to detect changes to set the exit code:
Just comparing hashes and comparing blob contents.  The latter is needed
if certain changes have to be ignored, e.g. with --ignore-space-change
or --ignore-matching-lines.  It's enabled by the diff_options flag
diff_from_contents.

The slower mode as never considered submodules (and subrepos) as changes
with --submodule=diff or --submodule=log, which is inconsistent with
--submodule=short (the default).  Fix it.

d7b97b7185 (diff: let external diffs report that changes are
uninteresting, 2024-06-09) set diff_from_contents if external diff
programs are allowed.  This is the default e.g. for git diff, and so
that change exposed the inconsistency much more widely.

Reported-by: David Hull &lt;david.hull@friendbuy.com&gt;
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
