Thread (15 messages) 15 messages, 5 authors, 5d ago

[PATCH v3 1/1] t1450: use 'mv -f' when overwriting a read-only file

flat view

From: <hidden>
Date: 2026-10-25 18:06:26
Subsystem: the rest · Maintainer: Linus Torvalds

From: Torsten Bögershausen <redacted>

Test case 38 in t/t1450-fsck.sh ("rev-list --verify-objects with
truncated loose blob") replaces a loose blob with a truncated
version using `mv obj.tmp "$obj"`.

Because Git creates loose objects as read-only files, this step
attempts to overwrite a read-only file. When running the test,
older versions of macOS `mv(1)` (prior to 12.3)
will prompt the user for confirmation (somewhat shortened):

override r--r--r--  user/staff for .git/objects/fc/a75a5be3823dc0560da5?
(y/n [n]) not overwritten
fca75a5be3823dc0560da57ade678f212aeb33f6

As the answer is not 'y', the file is not overwritten and the
test case fails.

Use `mv -f` to force the overwrite and avoid the interactive
prompt.

Helped-By: Tuomas Ahola [off-list ref]
Helped-By: Junio C Hamano [off-list ref]
Signed-off-by: Torsten Bögershausen <redacted>
---
v3: Use a much shorter commit message, as suggested from Junio.
    Mention that MacOs 12.3 has fixed this.

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.53.0.154.g7c02d39fc2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help