From: tboegi@web.de
To: tboegi@web.de, git@vger.kernel.org, ps@pks.im
Subject: [PATCH v2 1/1] t1450: use mv -f when overwriting a read only file
Date: Sun, 25 Oct 2026 05:33:22 +0100 [thread overview]
Message-ID: <20261025043322.1766-1-tboegi@web.de> (raw)
In-Reply-To: <atmvASAoaCIpc_ca@pks.im>
From: Torsten Bögershausen <tboegi@web.de>
test case 38 in t/t1450-fsck.sh replaces a loose blob, "$tmp" below,
with a trucated version "obj.tmp" using
mv obj.tmp "$obj"
This fails on some sytems, like older MacOS.
`man mv`
includes this information:
The following options are available:
-f Do not prompt for confirmation before overwriting the destination
path. (The -f option overrides any previous -i or -n options.)
and further down:
If the destination path does not have a mode which permits writing, mv
prompts the user for confirmation as specified for the -i option.
Running the test case in debug and verbose mode `./t1450-fsck.sh -d -v`
shows this lines (which I have shortened to fit into 72 characters)
override r--r--r-- user/staff for .git/objects/fc/a75a5be3823dc0560da5?
(y/n [n]) not overwritten
fca75a5be3823dc0560da57ade678f212aeb33f6
POSIX mentions that the observed
"prompt to standard error and read a line from standard input"
should not be done if "standard input is a terminal".
So we may blame the "standard input is a terminal" logic to fail.
Side note: Answering with 'y' to the question of `mv` like this
(echo y | mv obj.tmp "$obj")
makes the test case pass.
To make things not too complicated use the most portable form
mv -f obj.tmp "$obj"
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
Thanks to all reviewers.
Changes since V1:
"should not be done when" -> "should not be done if"
Fix "mv -v": it must be "mv -f"
t/t1450-fsck.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 16cc5d5dcb..335dcbf0af 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -548,7 +548,7 @@ test_expect_success 'rev-list --verify-objects with truncated loose blob' '
# Truncate the loose blob such that its header can still be
# parsed, but reading the object data fails mid-stream.
test_copy_bytes 64 <"$obj" >obj.tmp &&
- mv obj.tmp "$obj" &&
+ mv -f obj.tmp "$obj" &&
test_must_fail git rev-list --verify-objects "$blob" 2>err &&
test_grep "hash mismatch" err
--
2.50.0.rc0.46.g7014b55638
next prev parent reply other threads:[~2026-10-25 4:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 23:02 What's cooking in git.git (Oct 2026, #06) Junio C Hamano
2026-10-20 18:51 ` Torsten Bögershausen
2026-10-21 5:45 ` Patrick Steinhardt
2026-10-21 17:46 ` Junio C Hamano
2026-10-22 4:37 ` Torsten Bögershausen
2026-10-22 6:36 ` Patrick Steinhardt
2026-10-24 18:30 ` [PATCH v1 1/1] t1450: use mv -f when overwriting a read only file tboegi
2026-10-24 19:37 ` Tuomas Ahola
2026-10-24 19:43 ` SZEDER Gábor
2026-10-25 4:31 ` Junio C Hamano
2026-10-25 4:33 ` tboegi [this message]
2026-10-25 7:06 ` [PATCH v2 " Tuomas Ahola
2026-10-25 9:02 ` Torsten Bögershausen
2026-10-25 16:47 ` Junio C Hamano
2026-10-25 18:06 ` [PATCH v3 1/1] t1450: use 'mv -f' when overwriting a read-only file tboegi
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=20261025043322.1766-1-tboegi@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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