<feed xmlns='http://www.w3.org/2005/Atom'>
<title>pub/scm/git/git.git/t/t7501-commit-basic-functionality.sh, branch seen</title>
<subtitle>Git source code mirror</subtitle>
<id>http://kernel.varnish.org/pub/scm/git/git.git/atom/t/t7501-commit-basic-functionality.sh?h=seen</id>
<link rel='self' href='http://kernel.varnish.org/pub/scm/git/git.git/atom/t/t7501-commit-basic-functionality.sh?h=seen'/>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/'/>
<updated>2026-07-27T19:58:38Z</updated>
<entry>
<title>t: use commit_body to extract commit message bodies</title>
<updated>2026-07-27T19:58:38Z</updated>
<author>
<name>Shlok Kulshreshtha</name>
<email>diy2903@gmail.com</email>
</author>
<published>2026-07-27T09:56:56Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=9539653b71ed1ab37302574f96544013b8829eb9'/>
<id>urn:sha1:9539653b71ed1ab37302574f96544013b8829eb9</id>
<content type='text'>
Replace the "git cat-file commit | sed" idiom with commit_body across the
test suite: 61 sites in 12 files, plus one local helper that wrapped the
same idiom. The idiom appears in four equivalent spellings -- piped or
written to a file first, "sed -e" or plain "sed", "\$" or "$" in the
address -- all producing byte-identical output; they all collapse to the
same commit_body call.

t7509-commit-authorship.sh defined its own local message_body() helper
around the idiom instead of spelling it out at each call site; remove the
helper and convert its six call sites to commit_body directly.

Two sites needed more than a mechanical substitution:

* t7600.sh ("merge --no-ff --edit") greps the raw commit object for a
  phrase before stripping its header for the final comparison. The
  phrase is part of the commit body, not the header, so the grep can
  run against the already-stripped body instead, letting both steps
  share one commit_body call.

* t3900-i18n-commit.sh pipes the stripped body into "iconv" to test
  re-encoding. Piping commit_body's output into "iconv" would reintroduce
  an exit-code hole one line after removing it elsewhere, so this site
  writes the body to a file first and reads that, keeping the &amp;&amp;-chain
  intact.

Some greps for sed -e "1,/^\*$/d" left unconverted, as they are not extracting a commit's message body:

* t9001-send-email.sh strips mail headers from a message file, not a
  commit object.
* t1450-fsck.sh strips the header off a hand-built commit object while
  constructing a malformed one for fsck to reject.
* t4014-format-patch.sh runs the same sed address on a ".patch" file,
  with an additional expression.

All converted files pass in full, and a deliberately failing
"git cat-file" now fails a converted test that previously passed.

Signed-off-by: Shlok Kulshreshtha &lt;diy2903@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t: convert grep assertions to test_grep</title>
<updated>2026-07-06T20:27:00Z</updated>
<author>
<name>Michael Montalbo</name>
<email>mmontalbo@gmail.com</email>
</author>
<published>2026-07-06T05:01:57Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=47f79f619834acdd39d39bd1d3b33bf57f80d0a2'/>
<id>urn:sha1:47f79f619834acdd39d39bd1d3b33bf57f80d0a2</id>
<content type='text'>
Replace bare grep with test_grep in test assertions across the
suite, including sourced test helpers (lib-*.sh, *-tests.sh).
test_grep prints the contents of the file being searched on
failure, making debugging easier than a bare grep which fails
silently.

Only assertion-style greps are converted: grep used as a filter
in pipelines, command substitutions, conditionals, or with
redirected I/O is left as-is with a "# lint-ok" annotation.
Existing '! test_grep' calls are rewritten to 'test_grep !' so
that the diagnostic output is preserved on failure.

test_grep requires the file it reads to exist, so '! grep'
assertions that inspect a file whose presence is conditional need
care.  In t5537 the '.git/shallow' file is still present after the
repack (the client remains shallow), so the assertion is
converted like any other.  In t1400 the '.git/packed-refs' file
exists only with the files backend, so its check is guarded with a
REFFILES prerequisite; the backend-agnostic 'git show-ref' check
that follows still runs under every backend.  In t7450 'git~2' is
the NTFS 8.3 short name of a '..git' file and only exists
when 8.3 short-name generation is enabled, so its check is guarded
with a 'test -f' on the path and uses test_grep inside the guard,
the same shape as t1400 (a plain test_grep would BUG when the
short name is absent).

The conversion was generated using a grep-assertion linter
(greplint.pl, added in the following commit) to identify bare
grep calls at command position.  To reproduce, from the t/
directory:

    # Step 1: annotate the two data-filter greps (grep produces
    # data, not a verdict) so the linter skips them.
    sed -i '/grep -vf before commits\.raw/s/$/ # lint-ok: data filter/' \
        t5326-multi-pack-bitmaps.sh
    sed -i '/grep -E "^\[0-9a-f\].*|| :/s/$/ # lint-ok: data filter/' \
        t5702-protocol-v2.sh

    # Step 1b: two '! grep' assertions need more than a mechanical
    # conversion; handle them by hand before the linter-driven steps
    # below so it leaves them alone.
    #
    # t1400: '.git/packed-refs' is absent under reftable, so guard the
    # check with REFFILES (a plain test_grep would BUG on the missing
    # file):
    #
    #      git update-ref -d HEAD $B &amp;&amp;
    #  -   ! grep "$m" .git/packed-refs &amp;&amp;
    #  +   if test_have_prereq REFFILES
    #  +   then
    #  +           test_grep ! "$m" .git/packed-refs
    #  +   fi &amp;&amp;
    #      test_must_fail git show-ref --verify -q $m
    #
    # t7450: git~2 is an NTFS 8.3 short name that exists only when
    # short-name generation is enabled, so guard the check on its
    # presence with 'test -f' and note in a comment why the path can
    # be absent (a plain test_grep would BUG when it is):
    #
    #  -   ! grep gitdir squatting-clone/d/a/git~2
    #  +   if test -f squatting-clone/d/a/git~2
    #  +   then
    #  +           test_grep ! gitdir squatting-clone/d/a/git~2
    #  +   fi

    # Step 2: reorder pre-existing '! test_grep' to 'test_grep !'
    # (must come before steps 3-4 so greplint does not see them)
    sed -i 's/! test_grep/test_grep !/' t0031-lockfile-pid.sh
    sed -i 's/! test_grep/test_grep !/' t5300-pack-object.sh
    sed -i 's/! test_grep/test_grep !/' t5319-multi-pack-index.sh

    # Step 3: convert '! grep' -&gt; 'test_grep !'
    perl greplint.pl *.sh 2&gt;&amp;1 | cut -d: -f1,2 |
    while IFS=: read f l; do
        sed -i "${l}s/! *grep/test_grep !/" "$f"
    done

    # Step 4: convert remaining 'grep' -&gt; 'test_grep'
    perl greplint.pl *.sh 2&gt;&amp;1 | cut -d: -f1,2 |
    while IFS=: read f l; do
        sed -i "${l}s/grep/test_grep/" "$f"
    done

To verify, run: make -C t test-greplint

Signed-off-by: Michael Montalbo &lt;mmontalbo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t: adapt existing PERL prerequisites</title>
<updated>2025-04-07T21:47:38Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-04-03T05:05:58Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=64b3eee038c22142724778c7e32265d0fa986248'/>
<id>urn:sha1:64b3eee038c22142724778c7e32265d0fa986248</id>
<content type='text'>
A couple of our tests depend on the PERL prerequisite even though it
isn't needed. These tests fall into one of the following classes:

  - The underlying logic used to be implemented in Perl but isn't
    anymore. Here we can simply drop the dependency altogether.

  - The test logic used to depend on Perl but doesn't anymore. Again, we
    can simply drop the dependency.

  - The test logic still relies on a Perl interpreter. These tests
    should use the newly introduced PERL_TEST_HELPERS prerequisite.

Adapt test cases accordingly.

Note that in t1006 we have to introduce another new prerequisite
depending on whether or not the IPC::Open2 module is available. Funny
enough, when starting to use `test_lazy_prereq` to do so we also get a
conflict of variables with the "script" variable that contains the Perl
logic because `test_run_lazy_prereq_` also sets that variable. We thus
rename the variable in t1006 to "perl_script".

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>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='http://kernel.varnish.org/pub/scm/git/git.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>notes-utils: free note trees when releasing copied notes</title>
<updated>2024-06-11T20:15:05Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-06-11T09:19:26Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=bb8c43d5cd9648f868e11e462392a38a43354692'/>
<id>urn:sha1:bb8c43d5cd9648f868e11e462392a38a43354692</id>
<content type='text'>
While we clear most of the members of `struct notes_rewrite_cfg` in
`finish_copy_notes_for_rewrite()`, we do not clear the notes tree. Fix
this to plug this memory leak.

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>builtin/commit: error out when passing untracked path with -i</title>
<updated>2024-04-03T21:55:22Z</updated>
<author>
<name>Ghanshyam Thakkar</name>
<email>shyamthakkar001@gmail.com</email>
</author>
<published>2024-04-03T18:14:50Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=ac5946e6248eb84458d236099f356e5e09e2482f'/>
<id>urn:sha1:ac5946e6248eb84458d236099f356e5e09e2482f</id>
<content type='text'>
When we provide a pathspec which does not match any tracked path
alongside --include, we do not error like without --include. If there
is something staged, it will commit the staged changes and ignore the
pathspec which does not match any tracked path. And if nothing is
staged, it will print the status. Exit code is 0 in both cases (unlike
without --include). This is also described in the TODO comment before
the relevant testcase.

Fix this by passing a character array to add_files_to_cache() to
collect the pathspec matching information and error out if the given
path is untracked. Also, amend the testcase to check for the error
message and remove the TODO comment.

Signed-off-by: Ghanshyam Thakkar &lt;shyamthakkar001@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t7501: add tests for --amend --signoff</title>
<updated>2024-01-17T21:31:16Z</updated>
<author>
<name>Ghanshyam Thakkar</name>
<email>shyamthakkar001@gmail.com</email>
</author>
<published>2024-01-17T16:13:55Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=cab11f4e4116bc2cb09fc83ed79aad4457a4e630'/>
<id>urn:sha1:cab11f4e4116bc2cb09fc83ed79aad4457a4e630</id>
<content type='text'>
Add tests for amending the commit to add Signed-off-by trailer. And
also to check if it does not add another trailer if one already exists.

Currently, there are tests for --signoff separately in t7501, however,
they are not tested with --amend.

Therefore, these tests belong with other similar tests of --amend in
t7501-commit-basic-functionality.

Helped-by: Phillip Wood &lt;phillip.wood123@gmail.com&gt;
Signed-off-by: Ghanshyam Thakkar &lt;shyamthakkar001@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t7501: add tests for --include and --only</title>
<updated>2024-01-17T21:31:15Z</updated>
<author>
<name>Ghanshyam Thakkar</name>
<email>shyamthakkar001@gmail.com</email>
</author>
<published>2024-01-17T16:13:54Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=4e4f576b0690ba039cc0db40e68ee4143acc9a4c'/>
<id>urn:sha1:4e4f576b0690ba039cc0db40e68ee4143acc9a4c</id>
<content type='text'>
Add tests for --only (-o) and --include (-i). This include testing
with or without staged changes for both -i and -o. Also to test
for committing untracked files with -i, -o and without -i/-o.

Some tests already exist in t7501 for testing --only, however,
it is only tested in combination with --amend and --allow-empty
and on to-be-born branch. The addition of these tests check, when
the pathspec is provided without using -only, that only the files
matching the pathspec get committed. This behavior is same when
we provide --only and it is checked by the tests.
(as --only is the default mode of operation when pathspec is
provided.)

As for --include, there is no prior test for checking if --include
also commits staged changes, thus add test for that. Along with
the tests also document a potential bug, in which, when provided
with -i and a pathspec that does not match any tracked path,
commit does not fail if there are staged changes. And when there
are no staged changes commit fails. However, no error is returned
to stderr in either of the cases. This is described in the TODO
comment before the relevent testcase.

And also add a test for checking incompatibilty when using -o and
-i together.

Thus, these tests belong in t7501 with other similar existing tests,
as described in the case of --only.

Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Helped-by: Christian Couder &lt;christian.couder@gmail.com&gt;
Signed-off-by: Ghanshyam Thakkar &lt;shyamthakkar001@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>tests: teach callers of test_i18ngrep to use test_grep</title>
<updated>2023-11-02T08:13:44Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-10-31T05:23:30Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=6789275d3780bcb950e6be8557aeedf160d4ad6d'/>
<id>urn:sha1:6789275d3780bcb950e6be8557aeedf160d4ad6d</id>
<content type='text'>
They are equivalents and the former still exists, so as long as the
only change this commit makes are to rewrite test_i18ngrep to
test_grep, there won't be any new bug, even if there still are
callers of test_i18ngrep remaining in the tree, or when merged to
other topics that add new uses of test_i18ngrep.

This patch was produced more or less with

    git grep -l -e 'test_i18ngrep ' 't/t[0-9][0-9][0-9][0-9]-*.sh' |
    xargs perl -p -i -e 's/test_i18ngrep /test_grep /'

and a good way to sanity check the result yourself is to run the
above in a checkout of c4603c1c (test framework: further deprecate
test_i18ngrep, 2023-10-31) and compare the resulting working tree
contents with the result of applying this patch to the same commit.
You'll see that test_i18ngrep in a few t/lib-*.sh files corrected,
in addition to the manual reproduction.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>tests: use test_write_lines() to generate line-oriented output</title>
<updated>2021-12-13T18:29:48Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2021-12-09T05:11:05Z</published>
<link rel='alternate' type='text/html' href='http://kernel.varnish.org/pub/scm/git/git.git/commit/?id=0849541268a3aca9381591aed87b6864a203709b'/>
<id>urn:sha1:0849541268a3aca9381591aed87b6864a203709b</id>
<content type='text'>
Take advantage of test_write_lines() to generate line-oriented output
rather than using for-loops or a series of `echo` commands. Not only is
test_write_lines() a natural fit for such a task, but there is less
opportunity for a broken &amp;&amp;-chain.

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>
</feed>
