🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #1426

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

#1426
From: Tuomas Ahola
Date: Sun, 25 Oct 2026 07:06
97 lines
12787 bytes
tboegi@web.de wrote:

> 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
> 

s/trucated/truncated/

> mv obj.tmp "$obj"
> 
> This fails on some sytems, like older MacOS.

s/sytems/systems

FWIW, it seems that the glitch was fixed in macOS 12.3 (file_cmds-353.100.22).

> `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".

This replaced "when" with "if" but the meaning didn't change.  The observed
behavior shouldn't happen if the stdin is _not_ a terminal.

> So we may blame the "standard input is a terminal" logic to fail.

Well, macOS versions older than 12.3 just don't have that logic in mv(1).
Can nonexisting logic fail?  (If somebody is interested, the actual change
in 12.3 was

@@ -265,12 +290,12 @@ do_move(const char *from, const char *to)
 		} else if (iflg) {
 			(void)fprintf(stderr, "overwrite %s? %s", to, YESNO);
 			ask = 1;
-		} else if (access(to, W_OK) && !stat(to, &sb)) {
+		} else if (access(to, W_OK) && !stat(to, &sb) && isatty(STDIN_FILENO)) {
 			strmode(sb.st_mode, modep);
 			(void)fprintf(stderr, "override %s%s%s/%s for %s? %s",
 			    modep + 1, modep[9] == ' ' ? "" : " ",

rather simple indeed.)

> 
> 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
> 

Thanks.
Technical Details
Message-ID: <20261025070641.GW33j%taahol@utu.fi>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73194-linux-kernel-git=dewy.ru
References: <atmvASAoaCIpc_ca@pks.im> <20261025043322.1766-1-tboegi@web.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73194-linux-kernel-git=dewy.ru
From: taahol@utu.fi (Tuomas Ahola)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v2 1/1] t1450: use mv -f when overwriting a read only
 file
Date: Sun, 25 Oct 2026 09:06:41 +0200
Organization: Usenet Network
Message-ID: <20261025070641.GW33j%taahol@utu.fi>
References: <atmvASAoaCIpc_ca@pks.im> <20261025043322.1766-1-tboegi@web.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="956964"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:DoM+saPqRRFkayJavRMNM78oHVk= sha256:bdgMkJOeMZhWTDHKnJQHIpkya1QxObz9to+RIqPbtl8=
	sha1:rXBTfWGm6f4R+8gcpAmqiVkmkpw= sha256:vveSx7ukwJzSVg+Ztj5udLZWhsTiTPvnjRpTIzUSlF8=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E06CB125B2B; Sun, 25 Oct 2026 10:07:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=utu.fi
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id LGtqjyg8TKWx;
	Sun, 25 Oct 2026 10:07:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-73194-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=utu.fi
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 1C799125B2A; Sun, 25 Oct 2026 10:06:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 7D165485C9; Sun, 25 Oct 2026 07:06:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1792912013;
	b=W8V/FMkes/tt6nkLY3dbiOE+4mH7mpf/Ix6FrFZQwNUZrGFLOPruwrn+wjPwjiT71Q2G
	 pBfUorHnUQ4WwXuzuESxlT94hjfOYGm8oeMNT5B546+LccL/2aeYEfcRCB3s/eUJl3W5F
	 Cv9dy7UpSzZ2Ous+HEeWP5yRHYMVoN+MlDZPK8VQvUSgEwfZ5EbeZ5U/5/K4VLp6KI0JP
	 acNcTfT8XJacNnSg5Qu0cPJB3MHT6IIUqyJG/8g3kAXDoc/Fv73VZRUIAuSpWAixQFWRN
	 dNHl/ogtYcIRLVY57n4e5HbJT++UadyIJtJCei1pCUrfO+aQcrOuvOwyES+K/aEFmGQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792912013;
	h=X-Original-To:Received:DMARC-Filter:Received:Received:Received:
	 Received:Date:From:To:CC:Subject:Message-ID:In-Reply-To:References:
	 User-Agent:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:X-ClientProxiedBy:X-FEAS-BEC-Info:
	 X-FEAS-Client-IP:X-FE-Last-Public-Client-IP:X-FE-Policy-ID:
	 X-FE-Hostname:DKIM-Signature;
	bh=s0jEno+FSLlWHdxINFIjhiVUPqEe2NbRnWKLg26bi34=;
	b=VNqKMYBW1A8MaQjeGx3OL6c4Z3nITYPyjscu0b3ksFxoXGrrT/hCcW5CPA0Y6zAIjnFw
	 TPBirdJUbgWQzH4BUpmsX9nDF3SVqVxvg5zCsVrl5GmKbgOyUBhWrRtI1scmuTyvKreXR
	 sLI4OTsEFVg/pNlPWPrXXkgZJFi4+w0kFXLF1c831d57KCNrZBEkFniPViWCPOj1hI6bS
	 YpO13xFCwv3J3nIVzsMAxwshj5eKRRe8CDK+WVoTiKoCsLcYCxbRQSP9jnP9G32U+oyf2
	 aKRzsJdSDXi2foc0Wr3QHWC4wdnhXIIGBHq0SXYvITFjPMm+Grpy/9qCgr8dK+BbJKA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=utu.fi header.i=@utu.fi header.a=rsa-sha256 header.s=out-utu-v3 header.b=RIYkIGy+;
	dmarc=pass header.from=utu.fi;
	spf=pass smtp.mailfrom=utu.fi;
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 556F2606A321;
	Sun, 25 Oct 2026 07:06:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=utu.fi header.i=@utu.fi header.a=rsa-sha256 header.s=out-utu-v3 header.b=RIYkIGy+
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=130.232.247.4
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792912012;
	b=0WdSX1chVTZtyv+aFh0HM4rQbuH3iWpREga8IqhjvWQRwieQSNQKBRl0CE0dV5wzgF8W
	 6LfZl1I38S6EcXd7Iz9sez2XaFducA+nfPjvCYIWoTgJn2nC8+xLR/JrXqHy08hX1E72Q
	 1Kf4q4FsMXDB6HAYm66fRKtS6Yi/3Nhhun6HuSB3Hd0fXX9xoUQ0c5r9Hhis48v2PepfE
	 5Jo16MpAi3hiFq8pgPHdiZA8plPNq3E+MR7AuFQBFnoBBEWgsaX0K+SJHTMOBFwo+FpQA
	 aYK5EnUgEj2gImqti52KHR+CKv+JcWThJMhsOADcy1dzRL7DK68GI5431Xj58FjDXCA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792912012;
	h=DMARC-Filter:Received:Received:Received:Received:Date:From:To:CC:
	 Subject:Message-ID:In-Reply-To:References:User-Agent:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:X-Originating-IP:
	 X-ClientProxiedBy:X-FEAS-BEC-Info:X-FEAS-Client-IP:
	 X-FE-Last-Public-Client-IP:X-FE-Policy-ID:X-FE-Hostname:
	 DKIM-Signature;
	bh=s0jEno+FSLlWHdxINFIjhiVUPqEe2NbRnWKLg26bi34=;
	b=aLCFP0F1nPApN+f6OqupSGy3NxwmWhaCrENDVlzadzj3ZqErub3NRh5D98qn7eWxUHul
	 bFML2hP7/SrfsTOvksdvkDdErd0/+SNy0qX7WhulT3F6Q39kkLDSf3c5qcLVNWBNGd8Dx
	 d5iBZ/k77whBpO1cIPC/VPnlNS3f+xOIuMMnykpyb2RWmQvyvO2WEtaKCtd8fsqYTdq9F
	 2PcttvTojf9y9We8C4vI4f/o3FsIXxuPWz6aeFn7/xxUCP8kt17mqrPrqrhP37iCtdAhL
	 9PKjNMCyWnhpICP+3AKJymtFBJdIrmyDyZBgZgchV50kCp509Ckup+YRqMdHLuRuN8Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=utu.fi;
	spf=pass smtp.mailfrom=utu.fi;
	dkim=pass header.d=utu.fi header.i=@utu.fi header.a=rsa-sha256 header.s=out-utu-v3 header.b=RIYkIGy+;
	arc=none smtp.remote-ip=130.232.247.4
X-Received: from fortymile.utu.fi (fortymile.utu.fi [130.232.247.4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 628E1606A31B
	for <git@vger.kernel.org>; Sun, 25 Oct 2026 07:06:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 628E1606A31B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=utu.fi
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=utu.fi
X-Received: from smtp-03.utu.fi (smtp-03.utu.fi [130.232.207.30])
	by fortymile.utu.fi  with ESMTPS id 69P76gd7008645-69P76gd9008645
	(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO);
	Sun, 25 Oct 2026 09:06:42 +0200
X-Received: from ex19-06.utu.fi ([130.232.247.46])
	by smtp-03.utu.fi with esmtps  (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
	(Exim 4.95)
	(envelope-from <taahol@utu.fi>)
	id 1xKsJW-006AOo-Hb;
	Sun, 25 Oct 2026 09:06:42 +0200
X-Received: from localhost (86.50.95.90) by ex19-06.utu.fi (130.232.247.46) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Sun, 25 Oct
 2026 09:06:42 +0200
X-Received: from localhost (localhost [local])
	by localhost (OpenSMTPD) with ESMTPA id 56e1acf7;
	Sun, 25 Oct 2026 07:06:41 +0000 (UTC)
X-CC: <git@vger.kernel.org>, <ps@pks.im>, SZEDER Gábor
	<szeder.dev@gmail.com>
X-In-Reply-To: <20261025043322.1766-1-tboegi@web.de>
X-User-Agent: s-nail v14.9.22
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-ClientProxiedBy: ex19-05.utu.fi (130.232.247.45) To ex19-06.utu.fi
 (130.232.247.46)
X-FEAS-BEC-Info: WlpIGw0aAQkEARIJHAEHBlJSCRoLAAEeDUhZUEhYSFhIWkhZXkguLT4lWFxYWFhYWFBeUVxfSFhISFlbSBwJCQAHBCgdHB1GDgFIWUhaWEgbEg0MDRpGDA0eKA8FCQEE
 RgsHBUhYSFpIWVxIWVtYRlpbWkZaWF9GW1hIUEhYSFhIXEhYSFhIWEhZUUgPARwoHg8NGkYDDRoGDQRGBxoPSFhIUUgYGygYAxtGAQVIWEhaWEgbEg0MDRpGDA0eKA8F
 CQEERgsHBUhYSFlbSBwKBw0PASgfDQpGDA1IWA==
X-FEAS-Client-IP: 130.232.207.30
X-FE-Last-Public-Client-IP: 130.232.207.30
X-FE-Policy-ID: 3:5:2:SYSTEM
X-FE-Hostname: fortymile.utu.fi
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=utu.fi; s=out-utu-v3; c=relaxed/relaxed;
 h=date:from:to:cc:subject:message-id:references:mime-version:content-type;
 bh=s0jEno+FSLlWHdxINFIjhiVUPqEe2NbRnWKLg26bi34=;
 b=RIYkIGy+midj9H6Al0f51OwjJSI5uMIR8mQMM12lIeFZrCiE0SWuNrFE/K59Hz0t84C1XhB40R1Q
	EPPG4WHeAdHHn4Q/lULKUasm/RkYWiUk5pAdXbGY6x96Yv2CCDftttq4oYWcnkT4Nqr/r4r0XTdq
	2q/WxAayZ0oVHKlQLf17slbgKjj7VNClTCjVhpBTWjoM8WQ8slIxBXSs+uC7sHRQsWgYP+8raD2B
	A6G8YZbBPATrFdoafVpEfh+Qf+RNlPjD68JdwJEPhSOHoC7hIDjlwASYSsJRG0V0LHI5DcR9zRyD
	QEB2c/75Xv6vqCHSR0/gJ16MWXDE2DpOt3wcVA==