<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/t/t4051-diff-function-context.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>2024-11-20T23:23:48Z</updated>
<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>leak tests: mark passing SANITIZE=leak tests as leak-free</title>
<updated>2022-07-27T23:35:40Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-07-27T23:13:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3e3b9321cae0a09c066d1ff78f986d7382ea6898'/>
<id>urn:sha1:3e3b9321cae0a09c066d1ff78f986d7382ea6898</id>
<content type='text'>
Mark those remaining tests that pass when run under SANITIZE=leak with
TEST_PASSES_SANITIZE_LEAK=true, these were either omitted in
f346fcb62a0 (Merge branch 'ab/mark-leak-free-tests-even-more',
2021-12-15) and 5a4f8381b68 (Merge branch 'ab/mark-leak-free-tests',
2021-10-25), or have had their memory leaks fixed since then.

With this change there's now a a one-to-one mapping between those
tests that we have opted-in via "TEST_PASSES_SANITIZE_LEAK=true", and
those that pass with the new "check" mode:

	GIT_TEST_PASSING_SANITIZE_LEAK=check \
	GIT_TEST_SANITIZE_LEAK_LOG=true \
	make test SANITIZE=leak

Note that the "GIT_TEST_SANITIZE_LEAK_LOG=true" is needed due to the
edge cases noted in a preceding commit, i.e. in some cases we'd pass
the test itself, but still have outstanding leaks due to ignored exit
codes.

The "GIT_TEST_SANITIZE_LEAK_LOG=true" corrects for that, we're only
marking those tests as passing that really don't have any leaks,
whether that was reflected in their exit code or not.

Note that the change here to "t9100-git-svn-basic.sh" is marking that
test as passing under SANITIZE=leak, we're removing a
"TEST_FAILS_SANITIZE_LEAK=true" line, not
"TEST_PASSES_SANITIZE_LEAK=true". See 7a98d9ab00d (revisions API: have
release_revisions() release "cmdline", 2022-04-13) for the
introduction of that t/lib-git-svn.sh-specific variable.

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>Merge branch 'sg/t4051-fix'</title>
<updated>2018-08-27T21:33:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-08-27T21:33:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=603160b17e1884da3584dc5b424ecea4865c3d52'/>
<id>urn:sha1:603160b17e1884da3584dc5b424ecea4865c3d52</id>
<content type='text'>
Test fixes.

* sg/t4051-fix:
  t4051-diff-function-context: read the right file
</content>
</entry>
<entry>
<title>t4051-diff-function-context: read the right file</title>
<updated>2018-08-22T16:14:24Z</updated>
<author>
<name>SZEDER Gábor</name>
<email>szeder.dev@gmail.com</email>
</author>
<published>2018-08-22T12:44:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c8b35b95e1990df7d325e08cf35e59f8eb77cf48'/>
<id>urn:sha1:c8b35b95e1990df7d325e08cf35e59f8eb77cf48</id>
<content type='text'>
The test ' context does not include preceding empty lines' in the
block of tests 'change with long common tail and no context' in
't4051-diff-function-context.sh' tries to read the file
'long_common_tail.diff.diff', but that file doesn't exist as its name
contains one more '.diff' suffixes than necessary.

Despite this error the test still succeeded without checking what it's
supposed to, because this erroneous read is done on the line:

  test "$(first_context_line &lt;long_common_tail.diff.diff)" != " "

which means that:

  - the command substitution hides the error, so it won't fail the
    test, and

  - the result of the command substitution is the empty string, which
    is, of course, not equal to a single space character, so the
    condition is fulfilled, and the test succeeds.

As a minimal fix, fix the name of the file to be read.

In the future we might want to reorganize this test script (1) to use
'test_cmp' instead of 'test's and command substitutions to catch
failing commands and to provide helpful error messages, and (2) to
specify what the expected result actually _is_ instead of what it
isn't.

Signed-off-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: show non-empty lines before functions with -W</title>
<updated>2017-11-21T00:36:06Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-11-18T18:05:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5c3ed90f3f56757f2af9cc327313e9df2e38cdd5'/>
<id>urn:sha1:5c3ed90f3f56757f2af9cc327313e9df2e38cdd5</id>
<content type='text'>
Non-empty lines before a function definition are most likely comments
for that function and thus relevant.  Include them in function context.

Such a non-empty line might also belong to the preceeding function if
there is no separating blank line.  Stop extending the context upwards
also at the next function line to make sure only one extra function body
is shown at most.

Original-patch-by: Vegard Nossum &lt;vegard.nossum@oracle.com&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t4051: add test for comments preceding function lines</title>
<updated>2017-11-21T00:36:06Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-11-18T18:04:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eced93bcb8647ad7dad6511e0d58a4dad470f473'/>
<id>urn:sha1:eced93bcb8647ad7dad6511e0d58a4dad470f473</id>
<content type='text'>
When showing function context it would be helpful to show comments
immediately before declarations, as they are most likely relevant.

Add a test for that, but without specifying the choice of lines too
rigidly in the test---we may want to stop before and not include
"/*" in the future, for example.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff: enable indent heuristic by default</title>
<updated>2017-05-09T03:24:35Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2017-05-08T16:03:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=33de7163879ca83be7d6e1583c125f84e1e7c329'/>
<id>urn:sha1:33de7163879ca83be7d6e1583c125f84e1e7c329</id>
<content type='text'>
The feature was included in v2.11 (released 2016-11-29) and we got no
negative feedback. Quite the opposite, all feedback we got was positive.

Turn it on by default. Users who dislike the feature can turn it off
by setting diff.indentHeuristic (which also configures plumbing commands,
see prior patches).

The change to t/t4051-diff-function-context.sh is needed because the
heuristic shifts the changed hunk in the patch.  To get the same result
regardless of the heuristic configuration, we modify the test file
differently:  We insert a completely new line after line 2, instead of
simply duplicating it.

Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Marc Branchaud &lt;marcnarc@xiplink.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: fix merging of hunks with -W context and -u context</title>
<updated>2016-09-14T23:07:21Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-09-14T16:05:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=45d2f75f913c0545be473db1dc2595a1600413f5'/>
<id>urn:sha1:45d2f75f913c0545be473db1dc2595a1600413f5</id>
<content type='text'>
If the function context for a hunk (with -W) reaches the beginning of
the next hunk then we need to merge these two -- otherwise we'd show
some lines twice, which looks strange and even confuses git apply.  We
already do this checking and merging in xdl_emit_diff(), but forget to
consider regular context (with -u or -U).

Fix that by merging hunks already if function context of the first one
touches or overlaps regular context of the second one.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: fix merging of appended hunk with -W</title>
<updated>2016-06-09T22:27:26Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-06-09T21:54:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6f8d9bccb2c3694c62d14225976689c1e8c50fa5'/>
<id>urn:sha1:6f8d9bccb2c3694c62d14225976689c1e8c50fa5</id>
<content type='text'>
When -W is given we search the lines between the end of the current
context and the next change for a function line.  If there is none then
we merge those two hunks as they must be part of the same function.

If the next change is an appended chunk we abort the search early in
get_func_line(), however, because its line number is out of range.  Fix
that by searching from the end of the pre-image in that case instead.

Reported-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: don't trim common tail with -W</title>
<updated>2016-05-31T20:08:56Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-05-28T15:04:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e0876bca4de44638a1cb51b03bdf0a40df631a80'/>
<id>urn:sha1:e0876bca4de44638a1cb51b03bdf0a40df631a80</id>
<content type='text'>
The function trim_common_tail() exits early if context lines are
requested.  If -U0 and -W are specified together then it can still trim
context lines that might belong to a changed function.  As a result
that function is shown incompletely.

Fix that by calling trim_common_tail() only if no function context or
fixed context is requested.  The parameter ctx is no longer needed now;
remove it.

While at it fix an outdated comment as well.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
