From: Junio C Hamano <gitster@pobox.com>
To: "Michael Montalbo via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "D. Ben Knoble" <ben.knoble@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"SZEDER Gábor" <szeder.dev@gmail.com>,
"Michael Montalbo" <mmontalbo@gmail.com>
Subject: Re: [PATCH v3 0/6] t: add greplint.pl and convert grep to test_grep
Date: Sat, 04 Jul 2026 18:38:02 -0700 [thread overview]
Message-ID: <xmqqtsqedxmt.fsf@gitster.g> (raw)
In-Reply-To: <pull.2135.v3.git.1783054466.gitgitgadget@gmail.com> (Michael Montalbo via GitGitGadget's message of "Fri, 03 Jul 2026 04:54:19 +0000")
"Michael Montalbo via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Changes since v2:
>
> * t3420-rebase-autostash: dropped the change to the '! grep dirty file3'
> line under 'rebase --quit'. As SZEDER pointed out, file3 never exists in
> the conflicted state, so that grep was passing only because it could not
> open the file. SZEDER's fix (sg/t3420-do-not-grep-in-missing-file, now in
> 'next') replaces the line with 'test_path_is_missing file3', which is the
> right check; this series simply leaves that line to his fix.
>
> * Audited the remaining '# lint-ok' annotations for the same "grep a file
> that never exists with correctly running Git" gotcha, as Junio suggested.
> The rule the audit applies: 'grep' becomes 'test_grep' only where its
> exit code is the assertion; grep that produces data (a filter) or that
> reads a file whose presence is conditional stays a plain 'grep', because
> test_grep BUGs on a missing file.
>
> * t5537 (.git/shallow): the file is still present after the repack (the
> client stays shallow), so the assertion is converted to 'test_grep !'
> like any other; the "may not exist" note was wrong.
>
> * t1400 (.git/packed-refs): the file exists only with the files backend.
> Guarded the packed-refs check with a REFFILES prerequisite; the
> backend-agnostic 'git show-ref' check that follows still runs under
> every backend.
>
> * t7450 (squatting-clone/d/a/git~2): kept as '! grep' with an improved '#
> lint-ok'. 'git~2' is the NTFS 8.3 short name of a planted '..git' decoy
> and only exists when 8.3 short-name generation is enabled. Verified on
> a Windows VM: with 8.3 disabled (the modern default) the short name is
> absent, the '! grep' correctly tolerates it, and a plain test_grep
> would BUG. So this one deliberately stays a missing-file-tolerant grep.
>
> * t5326 and t5702 remain annotated: these are genuine data filters (grep
> produces data that is redirected/captured, not an assertion).
Great.
> ++ test_grep requires <file> to exist and will BUG otherwise.
> ++ When a file's presence is conditional (a backend-specific
> ++ file, or a path that only exists on some platforms, such as
> ++ an NTFS 8.3 short name), keep a plain guarded 'grep' instead.
It is not quite clear if I can follow this instruction myself,
without knowing what a "plain guarded 'grep'" is, unfortunately. Is
it different from bog-standard grep?
> @@ t/t1400-update-ref.sh: test_expect_success "move $m (by HEAD)" '
> test_when_finished "git update-ref -d $m" &&
> git update-ref -d HEAD $B &&
> - ! grep "$m" .git/packed-refs &&
> -+ ! grep "$m" .git/packed-refs && # lint-ok: file may not exist (reftable)
> ++ if test_have_prereq REFFILES
> ++ then
> ++ test_grep ! "$m" .git/packed-refs
> ++ fi &&
The intent is shown very well in this version (admittedly, the
lint-ok comment is readable but only by humans and LLMs). Here, we
expect .git/packed-refs only while REFFILES prerequiste is active.
Thanks.
next prev parent reply other threads:[~2026-07-05 1:38 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 7:45 [PATCH 0/6] t: add lint-style.pl and convert grep to test_grep Michael Montalbo via GitGitGadget
2026-06-04 7:45 ` [PATCH 1/6] t/README: document test_grep helper Michael Montalbo via GitGitGadget
2026-06-04 7:45 ` [PATCH 2/6] t: extract chainlint's parser into shared module Michael Montalbo via GitGitGadget
2026-06-04 7:45 ` [PATCH 3/6] t: fix Lexer line count for $() inside double-quoted strings Michael Montalbo via GitGitGadget
2026-06-04 7:45 ` [PATCH 4/6] t: add lint-style.pl with test_grep negation rule Michael Montalbo via GitGitGadget
2026-06-04 18:34 ` D. Ben Knoble
2026-06-04 19:36 ` Michael Montalbo
2026-06-04 7:45 ` [PATCH 5/6] t: fix grep assertions missing file arguments Michael Montalbo via GitGitGadget
2026-06-04 7:45 ` [PATCH 6/6] t: lint and convert grep assertions to test_grep Michael Montalbo via GitGitGadget
2026-06-08 21:36 ` [PATCH 0/6] t: add lint-style.pl and convert grep " Junio C Hamano
2026-06-13 16:28 ` Michael Montalbo
2026-06-13 4:06 ` [PATCH v2 0/6] t: add greplint.pl " Michael Montalbo via GitGitGadget
2026-06-13 4:06 ` [PATCH v2 1/6] t/README: document test_grep helper Michael Montalbo via GitGitGadget
2026-06-13 4:06 ` [PATCH v2 2/6] t: fix grep assertions missing file arguments Michael Montalbo via GitGitGadget
2026-06-13 4:06 ` [PATCH v2 3/6] t: extract chainlint's parser into shared module Michael Montalbo via GitGitGadget
2026-06-13 4:06 ` [PATCH v2 4/6] t: fix Lexer line count for $() inside double-quoted strings Michael Montalbo via GitGitGadget
2026-06-13 4:06 ` [PATCH v2 5/6] t: convert grep assertions to test_grep Michael Montalbo via GitGitGadget
2026-06-27 7:08 ` SZEDER Gábor
2026-06-27 14:36 ` Junio C Hamano
2026-06-28 1:41 ` Junio C Hamano
2026-06-28 2:03 ` Junio C Hamano
2026-06-29 21:21 ` Junio C Hamano
2026-07-02 4:14 ` Michael Montalbo
2026-06-13 4:06 ` [PATCH v2 6/6] t: add greplint to detect bare grep assertions Michael Montalbo via GitGitGadget
2026-07-03 4:54 ` [PATCH v3 0/6] t: add greplint.pl and convert grep to test_grep Michael Montalbo via GitGitGadget
2026-07-03 4:54 ` [PATCH v3 1/6] t/README: document test_grep helper Michael Montalbo via GitGitGadget
2026-07-03 4:54 ` [PATCH v3 2/6] t: fix grep assertions missing file arguments Michael Montalbo via GitGitGadget
2026-07-03 4:54 ` [PATCH v3 3/6] t: extract chainlint's parser into shared module Michael Montalbo via GitGitGadget
2026-07-03 4:54 ` [PATCH v3 4/6] t: fix Lexer line count for $() inside double-quoted strings Michael Montalbo via GitGitGadget
2026-07-03 4:54 ` [PATCH v3 5/6] t: convert grep assertions to test_grep Michael Montalbo via GitGitGadget
2026-07-03 4:54 ` [PATCH v3 6/6] t: add greplint to detect bare grep assertions Michael Montalbo via GitGitGadget
2026-07-05 1:38 ` Junio C Hamano [this message]
2026-07-05 2:49 ` [PATCH v3 0/6] t: add greplint.pl and convert grep to test_grep Michael Montalbo
2026-07-06 5:01 ` [PATCH v4 " Michael Montalbo via GitGitGadget
2026-07-06 5:01 ` [PATCH v4 1/6] t/README: document test_grep helper Michael Montalbo via GitGitGadget
2026-07-06 5:01 ` [PATCH v4 2/6] t: fix grep assertions missing file arguments Michael Montalbo via GitGitGadget
2026-07-06 5:01 ` [PATCH v4 3/6] t: extract chainlint's parser into shared module Michael Montalbo via GitGitGadget
2026-07-06 5:01 ` [PATCH v4 4/6] t: fix Lexer line count for $() inside double-quoted strings Michael Montalbo via GitGitGadget
2026-07-06 5:01 ` [PATCH v4 5/6] t: convert grep assertions to test_grep Michael Montalbo via GitGitGadget
2026-07-06 5:01 ` [PATCH v4 6/6] t: add greplint to detect bare grep assertions Michael Montalbo via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqtsqedxmt.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=mmontalbo@gmail.com \
--cc=sunshine@sunshineco.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox