Skip to content

[GSoC][PATCH] t9160:modernize test path checking#2160

Open
HodaSalim wants to merge 1 commit intogit:masterfrom
HodaSalim:microproject/modernize-t9160
Open

[GSoC][PATCH] t9160:modernize test path checking#2160
HodaSalim wants to merge 1 commit intogit:masterfrom
HodaSalim:microproject/modernize-t9160

Conversation

@HodaSalim
Copy link

@HodaSalim HodaSalim commented Jan 5, 2026

No description provided.

@gitgitgadget-git
Copy link

Welcome to GitGitGadget

Hi @HodaSalim, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that either:

  • Your Pull Request has a good description, if it consists of multiple commits, as it will be used as cover letter.
  • Your Pull Request description is empty, if it consists of a single commit, as the commit message should be descriptive enough by itself.

You can CC potential reviewers by adding a footer to the PR description with the following syntax:

CC: Revi Ewer <revi.ewer@example.com>, Ill Takalook <ill.takalook@example.net>

NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description,
because it will result in a malformed CC list on the mailing list. See
example.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "revisions:" to state which subsystem the change is about, and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form /allow. A good way to find other contributors is to locate recent pull requests where someone has been /allowed:

Both the person who commented /allow and the PR author are able to /allow you.

An alternative is the channel #git-devel on the Libera Chat IRC network:

<newcontributor> I've just created my first PR, could someone please /allow me? https://github.com/gitgitgadget/git/pull/12345
<veteran> newcontributor: it is done
<newcontributor> thanks!

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

If you want to see what email(s) would be sent for a /submit request, add a PR comment /preview to have the email(s) sent to you. You must have a public GitHub email address for this. Note that any reviewers CC'd via the list in the PR description will not actually be sent emails.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail).

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the (raw) link), then import it into your mail program. If you use GMail, you can do this via:

curl -g --user "<EMailAddress>:<Password>" \
    --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):

Changes since v1:
- Fixed a typo in the commit message (found by ...)
- Added a code comment to ... as suggested by ...
...

To send a new iteration, just add another PR comment with the contents: /submit.

Need help?

New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join.

You may also be able to find help in real time in the developer IRC channel, #git-devel on Libera Chat. Remember that IRC does not support offline messaging, so if you send someone a private message and log out, they cannot respond to you. The scrollback of #git-devel is archived, though.

@HodaSalim HodaSalim changed the title [GSoC] t9160: modernize test path checking [GSoC][Microproject] t9160: modernize test path checking Jan 5, 2026
@dscho
Copy link
Member

dscho commented Jan 5, 2026

/allow

@gitgitgadget-git
Copy link

User HodaSalim is now allowed to use GitGitGadget.

@HodaSalim
Copy link
Author

/preview

@gitgitgadget-git
Copy link

Preview email sent as pull.2160.git.git.1767624256966.gitgitgadget@gmail.com

Replace old-style path checks with Git's dedicated test helpers:
- test -f → test_path_is_file
- test -d → test_path_is_dir
- test -s → test_file_not_empty

Found using: git grep "test -[efd]" t/

This improves test readability and provides better error messages
when path checks fail.

Signed-off-by: HodaSalim <hoda.s.salim@gmail.com>
@HodaSalim HodaSalim force-pushed the microproject/modernize-t9160 branch from 2ec9e93 to a69555e Compare January 5, 2026 14:49
@HodaSalim
Copy link
Author

/preview

@gitgitgadget-git
Copy link

Preview email sent as pull.2160.git.git.1767624627377.gitgitgadget@gmail.com

@HodaSalim HodaSalim changed the title [GSoC][Microproject] t9160: modernize test path checking [GSoC][PATCH] t9160:modernize test path checking Jan 5, 2026
@HodaSalim
Copy link
Author

/submit

@gitgitgadget-git
Copy link

Submitted as pull.2160.git.git.1767625195071.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2160/HodaSalim/microproject/modernize-t9160-v1

To fetch this version to local tag pr-git-2160/HodaSalim/microproject/modernize-t9160-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2160/HodaSalim/microproject/modernize-t9160-v1

@gitgitgadget-git
Copy link

Hoda Salim wrote on the Git mailing list (how to reply to this email):

From: HodaSalim <hoda.s.salim@gmail.com>

Replace old-style path checks with Git's dedicated test helpers:
- test -f → test_path_is_file
- test -d → test_path_is_dir
- test -s → test_file_not_empty

Fix typos with the word "subsequent"

Found using: git grep "test -[efd]" t/

This improves test readability and provides better error messages
when path checks fail.

Signed-off-by: HodaSalim <hoda.s.salim@gmail.com>
---
 t/t9160-git-svn-preserve-empty-dirs.sh | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/t/t9160-git-svn-preserve-empty-dirs.sh b/t/t9160-git-svn-preserve-empty-dirs.sh
index 36c6b1a12f..de32cf2542 100755
--- a/t/t9160-git-svn-preserve-empty-dirs.sh
+++ b/t/t9160-git-svn-preserve-empty-dirs.sh
@@ -61,15 +61,15 @@ test_expect_success 'clone svn repo with --preserve-empty-dirs' '
 
 # "$GIT_REPO"/1 should only contain the placeholder file.
 test_expect_success 'directory empty from inception' '
-	test -f "$GIT_REPO"/1/.gitignore &&
+	test_path_is_file "$GIT_REPO"/1/.gitignore &&
 	test $(find "$GIT_REPO"/1 -type f | wc -l) = "1"
 '
 
 # "$GIT_REPO"/2 and "$GIT_REPO"/3 should only contain the placeholder file.
 test_expect_success 'directory empty from subsequent svn commit' '
-	test -f "$GIT_REPO"/2/.gitignore &&
+	test_path_is_file "$GIT_REPO"/2/.gitignore &&
 	test $(find "$GIT_REPO"/2 -type f | wc -l) = "1" &&
-	test -f "$GIT_REPO"/3/.gitignore &&
+	test_path_is_file "$GIT_REPO"/3/.gitignore &&
 	test $(find "$GIT_REPO"/3 -type f | wc -l) = "1"
 '
 
@@ -77,7 +77,7 @@ test_expect_success 'directory empty from subsequent svn commit' '
 # generated for every sub-directory at some point in the repo's history.
 test_expect_success 'add entry to previously empty directory' '
 	test $(find "$GIT_REPO"/4 -type f | wc -l) = "1" &&
-	test -f "$GIT_REPO"/4/a/b/c/foo
+	test_path_is_file "$GIT_REPO"/4/a/b/c/foo
 '
 
 # The HEAD~2 commit should not have introduced .gitignore placeholder files.
@@ -102,14 +102,14 @@ test_expect_success 'clone svn repo with --placeholder-file specified' '
 
 # "$GIT_REPO"/5/.placeholder should be a file, and non-empty.
 test_expect_success 'placeholder namespace conflict with file' '
-	test -s "$GIT_REPO"/5/.placeholder
+	test_file_not_empty "$GIT_REPO"/5/.placeholder
 '
 
 # "$GIT_REPO"/6/.placeholder should be a directory, and the "$GIT_REPO"/6 tree
 # should only contain one file: the placeholder.
 test_expect_success 'placeholder namespace conflict with directory' '
-	test -d "$GIT_REPO"/6/.placeholder &&
-	test -f "$GIT_REPO"/6/.placeholder/.placeholder &&
+	test_path_is_dir "$GIT_REPO"/6/.placeholder &&
+	test_path_is_file "$GIT_REPO"/6/.placeholder/.placeholder &&
 	test $(find "$GIT_REPO"/6 -type f | wc -l) = "1"
 '
 
@@ -133,19 +133,19 @@ test_expect_success 'second set of svn commits and rebase' '
 
 # Check that --preserve-empty-dirs and --placeholder-file flag state
 # stays persistent over multiple invocations.
-test_expect_success 'flag persistence during subsqeuent rebase' '
-	test -f "$GIT_REPO"/7/.placeholder &&
+test_expect_success 'flag persistence during subsequent rebase' '
+	test_path_is_file "$GIT_REPO"/7/.placeholder &&
 	test $(find "$GIT_REPO"/7 -type f | wc -l) = "1"
 '
 
 # Check that placeholder files are properly removed when unnecessary,
 # even across multiple invocations.
-test_expect_success 'placeholder list persistence during subsqeuent rebase' '
-	test -f "$GIT_REPO"/1/file1.txt &&
+test_expect_success 'placeholder list persistence during subsequent rebase' '
+	test_path_is_file "$GIT_REPO"/1/file1.txt &&
 	test $(find "$GIT_REPO"/1 -type f | wc -l) = "1" &&
 
-	test -f "$GIT_REPO"/5/file1.txt &&
-	test -f "$GIT_REPO"/5/.placeholder &&
+	test_path_is_file "$GIT_REPO"/5/file1.txt &&
+	test_path_is_file "$GIT_REPO"/5/.placeholder &&
 	test $(find "$GIT_REPO"/5 -type f | wc -l) = "2"
 '
 
-- 
2.50.1 (Apple Git-155)

@gitgitgadget-git
Copy link

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

Hoda Salim <hoda.s.salim@gmail.com> writes:

> From: HodaSalim <hoda.s.salim@gmail.com>
>
> Replace old-style path checks with Git's dedicated test helpers:
> - test -f → test_path_is_file
> - test -d → test_path_is_dir
> - test -s → test_file_not_empty
>
> Fix typos with the word "subsequent"
>
> Found using: git grep "test -[efd]" t/
>
> This improves test readability and provides better error messages
> when path checks fail.

For a small change like this, the above is sufficient as all the
necessary things are described, but for future reference, we prefer
to explain things in this order:

 - Give an observation on how the current system works in the
   present tense (so no need to say "Currently X is Y", or
   "Previously X was Y" to describe the state before your change;
   just "X is Y" is enough), and discuss what you perceive as a
   problem in it.

 - Propose a solution (optional---often, problem description
   trivially leads to an obvious solution in reader's minds).

 - Give commands to somebody editing the codebase to "make it so",
   instead of saying "This commit does X".

You are going backwards ;-).

Will queue.  Thanks (and thanks for all the reviewers who helped
polish the draft to get to this v2).


>
> Signed-off-by: HodaSalim <hoda.s.salim@gmail.com>
> ---
>  t/t9160-git-svn-preserve-empty-dirs.sh | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/t/t9160-git-svn-preserve-empty-dirs.sh b/t/t9160-git-svn-preserve-empty-dirs.sh
> index 36c6b1a12f..de32cf2542 100755
> --- a/t/t9160-git-svn-preserve-empty-dirs.sh
> +++ b/t/t9160-git-svn-preserve-empty-dirs.sh
> @@ -61,15 +61,15 @@ test_expect_success 'clone svn repo with --preserve-empty-dirs' '
>  
>  # "$GIT_REPO"/1 should only contain the placeholder file.
>  test_expect_success 'directory empty from inception' '
> -	test -f "$GIT_REPO"/1/.gitignore &&
> +	test_path_is_file "$GIT_REPO"/1/.gitignore &&
>  	test $(find "$GIT_REPO"/1 -type f | wc -l) = "1"
>  '
>  
>  # "$GIT_REPO"/2 and "$GIT_REPO"/3 should only contain the placeholder file.
>  test_expect_success 'directory empty from subsequent svn commit' '
> -	test -f "$GIT_REPO"/2/.gitignore &&
> +	test_path_is_file "$GIT_REPO"/2/.gitignore &&
>  	test $(find "$GIT_REPO"/2 -type f | wc -l) = "1" &&
> -	test -f "$GIT_REPO"/3/.gitignore &&
> +	test_path_is_file "$GIT_REPO"/3/.gitignore &&
>  	test $(find "$GIT_REPO"/3 -type f | wc -l) = "1"
>  '
>  
> @@ -77,7 +77,7 @@ test_expect_success 'directory empty from subsequent svn commit' '
>  # generated for every sub-directory at some point in the repo's history.
>  test_expect_success 'add entry to previously empty directory' '
>  	test $(find "$GIT_REPO"/4 -type f | wc -l) = "1" &&
> -	test -f "$GIT_REPO"/4/a/b/c/foo
> +	test_path_is_file "$GIT_REPO"/4/a/b/c/foo
>  '
>  
>  # The HEAD~2 commit should not have introduced .gitignore placeholder files.
> @@ -102,14 +102,14 @@ test_expect_success 'clone svn repo with --placeholder-file specified' '
>  
>  # "$GIT_REPO"/5/.placeholder should be a file, and non-empty.
>  test_expect_success 'placeholder namespace conflict with file' '
> -	test -s "$GIT_REPO"/5/.placeholder
> +	test_file_not_empty "$GIT_REPO"/5/.placeholder
>  '
>  
>  # "$GIT_REPO"/6/.placeholder should be a directory, and the "$GIT_REPO"/6 tree
>  # should only contain one file: the placeholder.
>  test_expect_success 'placeholder namespace conflict with directory' '
> -	test -d "$GIT_REPO"/6/.placeholder &&
> -	test -f "$GIT_REPO"/6/.placeholder/.placeholder &&
> +	test_path_is_dir "$GIT_REPO"/6/.placeholder &&
> +	test_path_is_file "$GIT_REPO"/6/.placeholder/.placeholder &&
>  	test $(find "$GIT_REPO"/6 -type f | wc -l) = "1"
>  '
>  
> @@ -133,19 +133,19 @@ test_expect_success 'second set of svn commits and rebase' '
>  
>  # Check that --preserve-empty-dirs and --placeholder-file flag state
>  # stays persistent over multiple invocations.
> -test_expect_success 'flag persistence during subsqeuent rebase' '
> -	test -f "$GIT_REPO"/7/.placeholder &&
> +test_expect_success 'flag persistence during subsequent rebase' '
> +	test_path_is_file "$GIT_REPO"/7/.placeholder &&
>  	test $(find "$GIT_REPO"/7 -type f | wc -l) = "1"
>  '
>  
>  # Check that placeholder files are properly removed when unnecessary,
>  # even across multiple invocations.
> -test_expect_success 'placeholder list persistence during subsqeuent rebase' '
> -	test -f "$GIT_REPO"/1/file1.txt &&
> +test_expect_success 'placeholder list persistence during subsequent rebase' '
> +	test_path_is_file "$GIT_REPO"/1/file1.txt &&
>  	test $(find "$GIT_REPO"/1 -type f | wc -l) = "1" &&
>  
> -	test -f "$GIT_REPO"/5/file1.txt &&
> -	test -f "$GIT_REPO"/5/.placeholder &&
> +	test_path_is_file "$GIT_REPO"/5/file1.txt &&
> +	test_path_is_file "$GIT_REPO"/5/.placeholder &&
>  	test $(find "$GIT_REPO"/5 -type f | wc -l) = "2"
>  '

@gitgitgadget-git
Copy link

Hoda Salim wrote on the Git mailing list (how to reply to this email):

> Will queue.  Thanks (and thanks for all the reviewers who helped
> polish the draft to get to this v2).

Yeah, sorry about that. The patch was initially submitted using
GitGitGadget and I didn't really do a great job in the beginning to
reply to the GitGitGadget email.
Pushkar was the maintainer that kindly pointed out the misspelling. I
added him to the CC for visibility

Thank You,
Hoda


On Mon, Feb 2, 2026 at 9:00 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Hoda Salim <hoda.s.salim@gmail.com> writes:
>
> > From: HodaSalim <hoda.s.salim@gmail.com>
> >
> > Replace old-style path checks with Git's dedicated test helpers:
> > - test -f → test_path_is_file
> > - test -d → test_path_is_dir
> > - test -s → test_file_not_empty
> >
> > Fix typos with the word "subsequent"
> >
> > Found using: git grep "test -[efd]" t/
> >
> > This improves test readability and provides better error messages
> > when path checks fail.
>
> For a small change like this, the above is sufficient as all the
> necessary things are described, but for future reference, we prefer
> to explain things in this order:
>
>  - Give an observation on how the current system works in the
>    present tense (so no need to say "Currently X is Y", or
>    "Previously X was Y" to describe the state before your change;
>    just "X is Y" is enough), and discuss what you perceive as a
>    problem in it.
>
>  - Propose a solution (optional---often, problem description
>    trivially leads to an obvious solution in reader's minds).
>
>  - Give commands to somebody editing the codebase to "make it so",
>    instead of saying "This commit does X".
>
> You are going backwards ;-).
>
> Will queue.  Thanks (and thanks for all the reviewers who helped
> polish the draft to get to this v2).
>
>
> >
> > Signed-off-by: HodaSalim <hoda.s.salim@gmail.com>
> > ---
> >  t/t9160-git-svn-preserve-empty-dirs.sh | 26 +++++++++++++-------------
> >  1 file changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/t/t9160-git-svn-preserve-empty-dirs.sh b/t/t9160-git-svn-preserve-empty-dirs.sh
> > index 36c6b1a12f..de32cf2542 100755
> > --- a/t/t9160-git-svn-preserve-empty-dirs.sh
> > +++ b/t/t9160-git-svn-preserve-empty-dirs.sh
> > @@ -61,15 +61,15 @@ test_expect_success 'clone svn repo with --preserve-empty-dirs' '
> >
> >  # "$GIT_REPO"/1 should only contain the placeholder file.
> >  test_expect_success 'directory empty from inception' '
> > -     test -f "$GIT_REPO"/1/.gitignore &&
> > +     test_path_is_file "$GIT_REPO"/1/.gitignore &&
> >       test $(find "$GIT_REPO"/1 -type f | wc -l) = "1"
> >  '
> >
> >  # "$GIT_REPO"/2 and "$GIT_REPO"/3 should only contain the placeholder file.
> >  test_expect_success 'directory empty from subsequent svn commit' '
> > -     test -f "$GIT_REPO"/2/.gitignore &&
> > +     test_path_is_file "$GIT_REPO"/2/.gitignore &&
> >       test $(find "$GIT_REPO"/2 -type f | wc -l) = "1" &&
> > -     test -f "$GIT_REPO"/3/.gitignore &&
> > +     test_path_is_file "$GIT_REPO"/3/.gitignore &&
> >       test $(find "$GIT_REPO"/3 -type f | wc -l) = "1"
> >  '
> >
> > @@ -77,7 +77,7 @@ test_expect_success 'directory empty from subsequent svn commit' '
> >  # generated for every sub-directory at some point in the repo's history.
> >  test_expect_success 'add entry to previously empty directory' '
> >       test $(find "$GIT_REPO"/4 -type f | wc -l) = "1" &&
> > -     test -f "$GIT_REPO"/4/a/b/c/foo
> > +     test_path_is_file "$GIT_REPO"/4/a/b/c/foo
> >  '
> >
> >  # The HEAD~2 commit should not have introduced .gitignore placeholder files.
> > @@ -102,14 +102,14 @@ test_expect_success 'clone svn repo with --placeholder-file specified' '
> >
> >  # "$GIT_REPO"/5/.placeholder should be a file, and non-empty.
> >  test_expect_success 'placeholder namespace conflict with file' '
> > -     test -s "$GIT_REPO"/5/.placeholder
> > +     test_file_not_empty "$GIT_REPO"/5/.placeholder
> >  '
> >
> >  # "$GIT_REPO"/6/.placeholder should be a directory, and the "$GIT_REPO"/6 tree
> >  # should only contain one file: the placeholder.
> >  test_expect_success 'placeholder namespace conflict with directory' '
> > -     test -d "$GIT_REPO"/6/.placeholder &&
> > -     test -f "$GIT_REPO"/6/.placeholder/.placeholder &&
> > +     test_path_is_dir "$GIT_REPO"/6/.placeholder &&
> > +     test_path_is_file "$GIT_REPO"/6/.placeholder/.placeholder &&
> >       test $(find "$GIT_REPO"/6 -type f | wc -l) = "1"
> >  '
> >
> > @@ -133,19 +133,19 @@ test_expect_success 'second set of svn commits and rebase' '
> >
> >  # Check that --preserve-empty-dirs and --placeholder-file flag state
> >  # stays persistent over multiple invocations.
> > -test_expect_success 'flag persistence during subsqeuent rebase' '
> > -     test -f "$GIT_REPO"/7/.placeholder &&
> > +test_expect_success 'flag persistence during subsequent rebase' '
> > +     test_path_is_file "$GIT_REPO"/7/.placeholder &&
> >       test $(find "$GIT_REPO"/7 -type f | wc -l) = "1"
> >  '
> >
> >  # Check that placeholder files are properly removed when unnecessary,
> >  # even across multiple invocations.
> > -test_expect_success 'placeholder list persistence during subsqeuent rebase' '
> > -     test -f "$GIT_REPO"/1/file1.txt &&
> > +test_expect_success 'placeholder list persistence during subsequent rebase' '
> > +     test_path_is_file "$GIT_REPO"/1/file1.txt &&
> >       test $(find "$GIT_REPO"/1 -type f | wc -l) = "1" &&
> >
> > -     test -f "$GIT_REPO"/5/file1.txt &&
> > -     test -f "$GIT_REPO"/5/.placeholder &&
> > +     test_path_is_file "$GIT_REPO"/5/file1.txt &&
> > +     test_path_is_file "$GIT_REPO"/5/.placeholder &&
> >       test $(find "$GIT_REPO"/5 -type f | wc -l) = "2"
> >  '

@gitgitgadget-git
Copy link

This patch series was integrated into seen via 3f6c068.

@gitgitgadget-git gitgitgadget-git bot added the seen label Feb 2, 2026
@gitgitgadget-git
Copy link

This patch series was integrated into seen via 831969a.

@gitgitgadget-git
Copy link

This patch series was integrated into seen via 1168106.

@gitgitgadget-git
Copy link

This branch is now known as hs/t9160-test-paths.

@gitgitgadget-git
Copy link

This patch series was integrated into seen via e3bb321.

@gitgitgadget-git
Copy link

This patch series was integrated into next via 0d40107.

@gitgitgadget-git gitgitgadget-git bot added the next label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants