<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/t/t4012-diff-binary.sh, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-03-17T18:08:24Z</updated>
<entry>
<title>apply: report the location of corrupt patches</title>
<updated>2026-03-17T18:08:24Z</updated>
<author>
<name>Jialong Wang</name>
<email>jerrywang183@yahoo.com</email>
</author>
<published>2026-03-17T16:23:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c5e15c9a58c0b32ec8be3ae96434834124de175e'/>
<id>urn:sha1:c5e15c9a58c0b32ec8be3ae96434834124de175e</id>
<content type='text'>
When parsing a corrupt patch, git apply reports only the line number.
That does not tell the user which input the line number refers to.

Include the patch input path in the error message so the reported
location is easier to use.

Reset the line number for each patch input so the reported location stays
correct when multiple input files are provided.

Add tests for file input, standard input, multiple patch inputs, and
existing binary-diff corrupt patch cases.

Signed-off-by: Jialong Wang &lt;jerrywang183@yahoo.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t: remove TEST_PASSES_SANITIZE_LEAK annotations</title>
<updated>2024-11-20T23:23:48Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-11-20T13:39:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fc1ddf42af6742fae7e770cae20e30d7902014c0'/>
<id>urn:sha1:fc1ddf42af6742fae7e770cae20e30d7902014c0</id>
<content type='text'>
Now that the default value for TEST_PASSES_SANITIZE_LEAK is `true` there
is no longer a need to have that variable declared in all of our tests.
Drop it.

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>diff.c: use utf8_strwidth() to count display width</title>
<updated>2022-09-14T20:48:18Z</updated>
<author>
<name>Torsten Bögershausen</name>
<email>tboegi@web.de</email>
</author>
<published>2022-09-14T15:13:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=12fc4ad89e23af642a8614371ff80bc67cb3315d'/>
<id>urn:sha1:12fc4ad89e23af642a8614371ff80bc67cb3315d</id>
<content type='text'>
When unicode filenames (encoded in UTF-8) are used, the visible width
on the screen is not the same as strlen().

For example, `git log --stat` may produce an output like this:

[snip the header]

 Arger.txt  | 1 +
 Ärger.txt | 1 +
 2 files changed, 2 insertions(+)

A side note: the original report was about cyrillic filenames.
After some investigations it turned out that
a) This is not a problem with "ambiguous characters" in unicode
b) The same problem exists for all unicode code points (so we
  can use Latin based Umlauts for demonstrations below)

The 'Ä' takes the same space on the screen as the 'A'.
But needs one more byte in memory, so the the `git log --stat` output
for "Arger.txt" (!) gets mis-aligned:
The maximum length is derived from "Ärger.txt", 10 bytes in memory,
9 positions on the screen. That is why "Arger.txt" gets one extra ' '
for aligment, it needs 9 bytes in memory.
If there was a file "Ö", it would be correctly aligned by chance,
but "Öhö" would not.

The solution is of course, to use utf8_strwidth() instead of strlen()
when dealing with the width on screen.

And then there is another problem, code like this:
strbuf_addf(&amp;out, "%-*s", len, name);
(or using the underlying snprintf() function) does not align the
buffer to a minimum of len measured in screen-width, but uses the
memory count.

One could be tempted to wish that snprintf() was UTF-8 aware.
That doesn't seem to be the case anywhere (tested on Linux and Mac),
probably snprintf() uses the "bytes in memory"/strlen() approach to be
compatible with older versions and this will never change.

The basic idea is to change code in diff.c like this
strbuf_addf(&amp;out, "%-*s", len, name);

into something like this:
int padding = len - utf8_strwidth(name);
if (padding &lt; 0)
	padding = 0;
strbuf_addf(&amp;out, " %s%*s", name, padding, "");

The real change is slighty bigger, as it, as well, integrates two calls
of strbuf_addf() into one.

Tests:
Two things need to be tested:
 - The calculation of the maximum width
 - The calculation of padding

The name "textfile" is changed into "tëxtfilë", both have a width of 8.
If strlen() was used, to get the maximum width, the shorter "binfile" would
have been mis-aligned:
 binfile    | [snip]
 tëxtfilë | [snip]

If only "binfile" would be renamed into "binfilë":
 binfilë | [snip]
 textfile | [snip]

In order to verify that the width is calculated correctly everywhere,
"binfile" is renamed into "binfilë", giving 1 bytes more in strlen()
"tëxtfile" is renamed into "tëxtfilë", 2 byte more in strlen().

The updated t4012-diff-binary.sh checks the correct aligment:
 binfilë  | [snip]
 tëxtfilë | [snip]

Reported-by: Alexander Meshcheryakov &lt;alexander.s.m@gmail.com&gt;
Helped-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Signed-off-by: Torsten Bögershausen &lt;tboegi@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'es/test-chain-lint'</title>
<updated>2022-01-04T00:24:15Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-04T00:24:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4f4b18497aea75425506097de7225df8c7cf5c66'/>
<id>urn:sha1:4f4b18497aea75425506097de7225df8c7cf5c66</id>
<content type='text'>
Broken &amp;&amp;-chains in the test scripts have been corrected.

* es/test-chain-lint:
  t6000-t9999: detect and signal failure within loop
  t5000-t5999: detect and signal failure within loop
  t4000-t4999: detect and signal failure within loop
  t0000-t3999: detect and signal failure within loop
  tests: simplify by dropping unnecessary `for` loops
  tests: apply modern idiom for exiting loop upon failure
  tests: apply modern idiom for signaling test failure
  tests: fix broken &amp;&amp;-chains in `{...}` groups
  tests: fix broken &amp;&amp;-chains in `$(...)` command substitutions
  tests: fix broken &amp;&amp;-chains in compound statements
  tests: use test_write_lines() to generate line-oriented output
  tests: simplify construction of large blocks of text
  t9107: use shell parameter expansion to avoid breaking &amp;&amp;-chain
  t6300: make `%(raw:size) --shell` test more robust
  t5516: drop unnecessary subshell and command invocation
  t4202: clarify intent by creating expected content less cleverly
  t1020: avoid aborting entire test script when one test fails
  t1010: fix unnoticed failure on Windows
  t/lib-pager: use sane_unset() to avoid breaking &amp;&amp;-chain
</content>
</entry>
<entry>
<title>t4000-t4999: detect and signal failure within loop</title>
<updated>2021-12-13T18:29:48Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2021-12-09T05:11:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cbe1d9d630e529d3dd240eacf3d1c9799fef702b'/>
<id>urn:sha1:cbe1d9d630e529d3dd240eacf3d1c9799fef702b</id>
<content type='text'>
Failures within `for` and `while` loops can go unnoticed if not detected
and signaled manually since the loop itself does not abort when a
contained command fails, nor will a failure necessarily be detected when
the loop finishes since the loop returns the exit code of the last
command it ran on the final iteration, which may not be the command
which failed. Therefore, detect and signal failures manually within
loops using the idiom `|| return 1` (or `|| exit 1` within subshells).

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Reviewed-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>leak tests: mark some diff tests as passing with SANITIZE=leak</title>
<updated>2021-11-01T18:23:08Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-10-30T22:24:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=16d4bd4f14e91ab5f70fb74407fc27fc4c8bfe0f'/>
<id>urn:sha1:16d4bd4f14e91ab5f70fb74407fc27fc4c8bfe0f</id>
<content type='text'>
Mark some tests that match "*diff*" as passing when git is compiled
with SANITIZE=leak. They'll now be listed as running under the
"GIT_TEST_PASSING_SANITIZE_LEAK=true" test mode (the "linux-leaks" CI
target).

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>tests: remove most uses of test_i18ncmp</title>
<updated>2021-02-11T07:48:27Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-02-11T01:53:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1108cea7f8ee38a8507c1cc68d1fafe2eb31d623'/>
<id>urn:sha1:1108cea7f8ee38a8507c1cc68d1fafe2eb31d623</id>
<content type='text'>
As a follow-up to d162b25f956 (tests: remove support for
GIT_TEST_GETTEXT_POISON, 2021-01-20) remove most uses of test_i18ncmp
via a simple s/test_i18ncmp/test_cmp/g search-replacement.

I'm leaving t6300-for-each-ref.sh out due to a conflict with in-flight
changes between "master" and "seen", as well as the prerequisite
itself due to other changes between "master" and "next/seen" which add
new test_i18ncmp uses.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>tests: remove most uses of C_LOCALE_OUTPUT</title>
<updated>2021-02-11T07:48:26Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-02-11T01:53:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a926c4b904bdc339568c2898af955cdc61b31542'/>
<id>urn:sha1:a926c4b904bdc339568c2898af955cdc61b31542</id>
<content type='text'>
As a follow-up to d162b25f956 (tests: remove support for
GIT_TEST_GETTEXT_POISON, 2021-01-20) remove those uses of the now
always true C_LOCALE_OUTPUT prerequisite from those tests which
declare it as an argument to test_expect_{success,failure}.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t: use test_might_fail() instead of manipulating exit code manually</title>
<updated>2018-07-03T19:38:04Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-07-02T00:23:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=83279748594cf1c7a38ebf518cd6b63cd3d8de37'/>
<id>urn:sha1:83279748594cf1c7a38ebf518cd6b63cd3d8de37</id>
<content type='text'>
These tests manually coerce the exit code of invoked commands to
"success" when they don't care if the command succeeds or fails since
failure of those commands should not cause the test to fail overall.
In doing so, they intentionally break the &amp;&amp;-chain. Modernize by
replacing manual exit code management with test_might_fail() and a
normal &amp;&amp;-chain.

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin/apply: make parse_single_patch() return -1 on error</title>
<updated>2016-08-11T19:41:46Z</updated>
<author>
<name>Christian Couder</name>
<email>christian.couder@gmail.com</email>
</author>
<published>2016-08-08T21:03:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dae197f753c8b3ccdc9c97cfc04f0dbd99a5cc3c'/>
<id>urn:sha1:dae197f753c8b3ccdc9c97cfc04f0dbd99a5cc3c</id>
<content type='text'>
To libify `git apply` functionality we have to signal errors to the
caller instead of die()ing.

To do that in a compatible manner with the rest of the error handling
in builtin/apply.c, parse_single_patch() should return a negative
integer instead of calling die().

Let's do that by using error() and let's adjust the related test
cases accordingly.

Signed-off-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
