<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/diff.c, branch v2.39.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.39.2</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.39.2'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2022-11-28T03:13:46Z</updated>
<entry>
<title>Merge branch 'sg/plug-line-log-leaks'</title>
<updated>2022-11-28T03:13:46Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-11-28T03:13:45Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=613999cc5c951bc2c078caad59e339243f119a6e'/>
<id>urn:sha1:613999cc5c951bc2c078caad59e339243f119a6e</id>
<content type='text'>
A handful of leaks in the line-log machinery have been plugged.

* sg/plug-line-log-leaks:
  diff.c: use diff_free_queue()
  line-log: free the diff queues' arrays when processing merge commits
  line-log: free diff queue when processing non-merge commits
</content>
</entry>
<entry>
<title>Merge branch 'rs/no-more-run-command-v'</title>
<updated>2022-11-08T22:15:12Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2022-11-08T22:15:12Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=be4ac3b197f8b4070bdad65dea4a03e1389410a6'/>
<id>urn:sha1:be4ac3b197f8b4070bdad65dea4a03e1389410a6</id>
<content type='text'>
Simplify the run-command API.

* rs/no-more-run-command-v:
  replace and remove run_command_v_opt()
  replace and remove run_command_v_opt_cd_env_tr2()
  replace and remove run_command_v_opt_tr2()
  replace and remove run_command_v_opt_cd_env()
  use child_process members "args" and "env" directly
  use child_process member "args" instead of string array variable
  sequencer: simplify building argument list in do_exec()
  bisect--helper: factor out do_bisect_run()
  bisect: simplify building "checkout" argument list
  am: simplify building "show" argument list
  run-command: fix return value comment
  merge: remove always-the-same "verbose" arguments
</content>
</entry>
<entry>
<title>diff.c: use diff_free_queue()</title>
<updated>2022-11-03T00:16:34Z</updated>
<author>
<name>SZEDER Gábor</name>
<email>szeder.dev@gmail.com</email>
</author>
<published>2022-11-02T22:01:42Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=586d8b5052f6b98c262c872f54216e39f3d56625'/>
<id>urn:sha1:586d8b5052f6b98c262c872f54216e39f3d56625</id>
<content type='text'>
Use diff_free_queue() instead of open-coding it.  This shortens the
code and make it less repetitive.

Note that the second hunk in diff_flush() is interesting, because the
'free_queue' label separates the loop freeing the queue's filepairs
from free()-ing the queue's internal array.  This is somewhat
suspicious, but it was not an issue before: there is only one place
from where we jump to this label with a goto, and that is protected by
an 'if (!q-&gt;nr &amp;&amp; ...)' condition, i.e. we only skipped the loop
freeing the filepairs when there were no filepairs in the queue to
begin with.

Signed-off-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>line-log: free diff queue when processing non-merge commits</title>
<updated>2022-11-03T00:16:34Z</updated>
<author>
<name>SZEDER Gábor</name>
<email>szeder.dev@gmail.com</email>
</author>
<published>2022-11-02T22:01:40Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=04ae00062d2ec301828e8df9931817be4b2f8653'/>
<id>urn:sha1:04ae00062d2ec301828e8df9931817be4b2f8653</id>
<content type='text'>
When processing a non-merge commit, the line-level log first asks the
tree-diff machinery whether any of the files in the given line ranges
were modified between the current commit and its parent, and if some
of them were, then it loads the contents of those files from both
commits to see whether their line ranges were modified and/or need to
be adjusted.  Alas, it doesn't free() the diff queue holding the
results of that query and the contents of those files once its done.
This can add up to a substantial amount of leaked memory, especially
when the file in question is big and is frequently modified: a user
reported "Out of memory, malloc failed" errors with a 2MB text file
that was modified ~2800 times [1] (I estimate the leak would use up
almost 11GB memory in that case).

Free that diff queue to plug this memory leak.  However, instead of
simply open-coding the necessary three lines, add them as a helper
function to the diff API, because it will be useful elsewhere as well.

[1] https://public-inbox.org/git/CAFOPqVXz2XwzX8vGU7wLuqb2ZuwTuOFAzBLRM_QPk+NJa=eC-g@mail.gmail.com/

Signed-off-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jz/patch-id'</title>
<updated>2022-10-31T01:04:41Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2022-10-31T01:04:41Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=160314e62537274d88c939bed957f623cda13da4'/>
<id>urn:sha1:160314e62537274d88c939bed957f623cda13da4</id>
<content type='text'>
A new "--include-whitespace" option is added to "git patch-id", and
existing bugs in the internal patch-id logic that did not match
what "git patch-id" produces have been corrected.

* jz/patch-id:
  builtin: patch-id: remove unused diff-tree prefix
  builtin: patch-id: add --verbatim as a command mode
  patch-id: fix patch-id for mode changes
  builtin: patch-id: fix patch-id with binary diffs
  patch-id: use stable patch-id for rebases
  patch-id: fix stable patch id for binary / header-only
</content>
</entry>
<entry>
<title>use child_process members "args" and "env" directly</title>
<updated>2022-10-30T18:04:40Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2022-10-30T11:51:14Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=0e90673957f12adc1a84b13d3dfff02151e4a7a8'/>
<id>urn:sha1:0e90673957f12adc1a84b13d3dfff02151e4a7a8</id>
<content type='text'>
Build argument list and environment of child processes by using
struct child_process and populating its members "args" and "env"
directly instead of maintaining separate strvecs and letting
run_command_v_opt() and friends populate these members.  This is
simpler, shorter and slightly more efficient.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'tb/diffstat-with-utf8-strwidth'</title>
<updated>2022-10-28T18:26:55Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-10-28T18:26:55Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=7d5a4d86a652ababe2ee1bbd27dcf0ccd30dd1c0'/>
<id>urn:sha1:7d5a4d86a652ababe2ee1bbd27dcf0ccd30dd1c0</id>
<content type='text'>
"git diff --stat" etc. were invented back when everything was ASCII
and strlen() was a way to measure the display width of a string;
adjust them to compute the display width assuming UTF-8 pathnames.

* tb/diffstat-with-utf8-strwidth:
  diff: leave NEEDWORK notes in show_stats() function
  diff.c: use utf8_strwidth() to count display width
</content>
</entry>
<entry>
<title>patch-id: fix patch-id for mode changes</title>
<updated>2022-10-24T22:44:20Z</updated>
<author>
<name>Jerry Zhang</name>
<email>Jerry@skydio.com</email>
</author>
<published>2022-10-24T20:07:42Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=93105aba6c4c8608b10c8ebe14b2313b3d347124'/>
<id>urn:sha1:93105aba6c4c8608b10c8ebe14b2313b3d347124</id>
<content type='text'>
Currently patch-id as used in rebase and cherry-pick does not account
for file modes if the file is modified. One consequence of this is
that if you have a local patch that changes modes, but upstream
has applied an outdated version of the patch that doesn't include
that mode change, "git rebase" will drop your local version of the
patch along with your mode changes. It also means that internal
patch-id doesn't produce the same output as the builtin, which does
account for mode changes due to them being part of diff output.

Fix by adding mode to the patch-id if it has changed, in the same
format that would be produced by diff, so that it is compatible
with builtin patch-id.

Signed-off-by: Jerry Zhang &lt;Jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>patch-id: use stable patch-id for rebases</title>
<updated>2022-10-24T22:44:19Z</updated>
<author>
<name>Jerry Zhang</name>
<email>jerry@skydio.com</email>
</author>
<published>2022-10-24T20:07:40Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=51276c1832d64d3b8f4dfc06c3ef21bf74f1916e'/>
<id>urn:sha1:51276c1832d64d3b8f4dfc06c3ef21bf74f1916e</id>
<content type='text'>
Git doesn't persist patch-ids during the rebase process, so there is
no need to specifically invoke the unstable variant. Use the stable
logic for all internal patch-id calculations to minimize the number of
code paths and improve test coverage.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>patch-id: fix stable patch id for binary / header-only</title>
<updated>2022-10-24T22:44:19Z</updated>
<author>
<name>Jerry Zhang</name>
<email>jerry@skydio.com</email>
</author>
<published>2022-10-24T20:07:39Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=0570be79ead35e47e29ee2587e2c8ea47c091d49'/>
<id>urn:sha1:0570be79ead35e47e29ee2587e2c8ea47c091d49</id>
<content type='text'>
Patch-ids for binary patches are found by hashing the object
ids of the before and after objects in succession. However in
the --stable case, there is a bug where hunks are not flushed
for binary and header-only patch ids, which would always result
in a patch-id of 0000. The --unstable case is currently correct.

Reorder the logic to branch into 3 cases for populating the
patch body: header-only which populates nothing, binary which
populates the object ids, and normal which populates the text
diff. All branches will end up flushing the hunk.

Don't populate the ---a/ and +++b/ lines for binary diffs, to correspond
to those lines not being present in the "git diff" text output.
This is necessary because we advertise that the patch-id calculated
internally and used in format-patch is the same that what the
builtin "git patch-id" would produce when piped from a diff.

Update the test to run on both binary and normal files.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
