From: Meet Soni <meetsoni3017@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, karthik.188@gmail.com,
kaartic.sivaraam@gmail.com, ps@pks.im, shyamthakkar001@gmail.com,
shejialuo@gmail.com, chandrapratap3519@gmail.com,
Meet Soni <meetsoni3017@gmail.com>
Subject: [PATCH v2] t7611: replace test -f with test_path_is* helpers
Date: Fri, 20 Dec 2024 18:36:32 +0530 [thread overview]
Message-ID: <20241220130632.11826-1-meetsoni3017@gmail.com> (raw)
In-Reply-To: <20241218111715.1030357-1-meetsoni3017@gmail.com>
Replace `test -f` and `test ! -f` with `test_path_is_file` and
`test_path_is_missing` for better verbosity.
While `test -f` ensures that the file exists and is a regular file,
`test_path_is_file` provides clearer error messages on failure. Similarly,
`test ! -f`, used to check either the absence of a regular file or the
presence of a directory, has been replaced with `test_path_is_missing` for
better readability and consistent handling of such cases.
Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
---
Updated commit message and subject according to review.
t/t7611-merge-abort.sh | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/t/t7611-merge-abort.sh b/t/t7611-merge-abort.sh
index d6975ca48d..1a251485e1 100755
--- a/t/t7611-merge-abort.sh
+++ b/t/t7611-merge-abort.sh
@@ -54,13 +54,13 @@ test_expect_success 'fails without MERGE_HEAD (unstarted merge)' '
'
test_expect_success 'fails without MERGE_HEAD (unstarted merge): .git/MERGE_HEAD sanity' '
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)"
'
test_expect_success 'fails without MERGE_HEAD (completed merge)' '
git merge clean_branch &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
# Merge successfully completed
post_merge_head="$(git rev-parse HEAD)" &&
test_must_fail git merge --abort 2>output &&
@@ -68,7 +68,7 @@ test_expect_success 'fails without MERGE_HEAD (completed merge)' '
'
test_expect_success 'fails without MERGE_HEAD (completed merge): .git/MERGE_HEAD sanity' '
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$post_merge_head" = "$(git rev-parse HEAD)"
'
@@ -79,10 +79,10 @@ test_expect_success 'Forget previous merge' '
test_expect_success 'Abort after --no-commit' '
# Redo merge, but stop before creating merge commit
git merge --no-commit clean_branch &&
- test -f .git/MERGE_HEAD &&
+ test_path_is_file .git/MERGE_HEAD &&
# Abort non-conflicting merge
git merge --abort &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff)" &&
test -z "$(git diff --staged)"
@@ -91,10 +91,10 @@ test_expect_success 'Abort after --no-commit' '
test_expect_success 'Abort after conflicts' '
# Create conflicting merge
test_must_fail git merge conflict_branch &&
- test -f .git/MERGE_HEAD &&
+ test_path_is_file .git/MERGE_HEAD &&
# Abort conflicting merge
git merge --abort &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff)" &&
test -z "$(git diff --staged)"
@@ -105,7 +105,7 @@ test_expect_success 'Clean merge with dirty index fails' '
git add foo &&
git diff --staged > expect &&
test_must_fail git merge clean_branch &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff)" &&
git diff --staged > actual &&
@@ -114,7 +114,7 @@ test_expect_success 'Clean merge with dirty index fails' '
test_expect_success 'Conflicting merge with dirty index fails' '
test_must_fail git merge conflict_branch &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff)" &&
git diff --staged > actual &&
@@ -129,10 +129,10 @@ test_expect_success 'Reset index (but preserve worktree changes)' '
test_expect_success 'Abort clean merge with non-conflicting dirty worktree' '
git merge --no-commit clean_branch &&
- test -f .git/MERGE_HEAD &&
+ test_path_is_file .git/MERGE_HEAD &&
# Abort merge
git merge --abort &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff --staged)" &&
git diff > actual &&
@@ -141,10 +141,10 @@ test_expect_success 'Abort clean merge with non-conflicting dirty worktree' '
test_expect_success 'Abort conflicting merge with non-conflicting dirty worktree' '
test_must_fail git merge conflict_branch &&
- test -f .git/MERGE_HEAD &&
+ test_path_is_file .git/MERGE_HEAD &&
# Abort merge
git merge --abort &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff --staged)" &&
git diff > actual &&
@@ -159,7 +159,7 @@ test_expect_success 'Fail clean merge with conflicting dirty worktree' '
echo xyzzy >> bar &&
git diff > expect &&
test_must_fail git merge --no-commit clean_branch &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff --staged)" &&
git diff > actual &&
@@ -168,7 +168,7 @@ test_expect_success 'Fail clean merge with conflicting dirty worktree' '
test_expect_success 'Fail conflicting merge with conflicting dirty worktree' '
test_must_fail git merge conflict_branch &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff --staged)" &&
git diff > actual &&
@@ -183,7 +183,7 @@ test_expect_success 'Fail clean merge with matching dirty worktree' '
echo bart > bar &&
git diff > expect &&
test_must_fail git merge --no-commit clean_branch &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff --staged)" &&
git diff > actual &&
@@ -194,7 +194,7 @@ test_expect_success 'Fail conflicting merge with matching dirty worktree' '
echo barf > bar &&
git diff > expect &&
test_must_fail git merge conflict_branch &&
- test ! -f .git/MERGE_HEAD &&
+ test_path_is_missing .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
test -z "$(git diff --staged)" &&
git diff > actual &&
--
2.34.1
next prev parent reply other threads:[~2024-12-20 13:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 11:17 [GSoC] [PATCH] t7611: replace test -f with test_path_is* helpers Meet Soni
2024-12-18 15:23 ` karthik nayak
2024-12-20 13:06 ` Meet Soni [this message]
2024-12-20 14:16 ` [PATCH v2] " Junio C Hamano
2024-12-27 10:53 ` [PATCH v3] " Meet Soni
2024-12-27 12:19 ` Ghanshyam Thakkar
2024-12-27 16:15 ` Junio C Hamano
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=20241220130632.11826-1-meetsoni3017@gmail.com \
--to=meetsoni3017@gmail.com \
--cc=chandrapratap3519@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=kaartic.sivaraam@gmail.com \
--cc=karthik.188@gmail.com \
--cc=ps@pks.im \
--cc=shejialuo@gmail.com \
--cc=shyamthakkar001@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;
as well as URLs for NNTP newsgroup(s).