git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Torsten Bögershausen <tboegi@web.de>
Date
Oct 25, 2026, 09:02 UTC
Message-ID
<20261025090242.GA25750@tb-raspi4>
In-Reply-To
<20261025070641.GW33j%taahol@utu.fi>
On Sun, Oct 25, 2026 at 09:06:41AM +0200, Tuomas Ahola wrote:
Show 75 quoted lines
> 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"
> > 
[]
> Thanks.
> 

Thanks as well from my side - I will wait a little while before sending out v3

Previous: Tuomas AholaNext: Junio C Hamano
Message 13 of 15 in “What's cooking in git.git (Oct 2026, #06)”
  1. Junio C HamanoOct 16, 2026
  2. Torsten BögershausenOct 20, 2026
  3. Patrick SteinhardtOct 21, 2026
  4. Junio C HamanoOct 21, 2026
  5. Torsten BögershausenOct 22, 2026
  6. Patrick SteinhardtOct 22, 2026
  7. 1/1 t1450: use mv -f when overwriting a read only filetboegi@web.de, Oct 24, 2026
  8. Tuomas AholaOct 24, 2026
  9. SZEDER GáborOct 24, 2026
  10. Junio C HamanoOct 25, 2026
  11. 1/1 t1450: use mv -f when overwriting a read only filetboegi@web.de, Oct 25, 2026
  12. Tuomas AholaOct 25, 2026
  13. Torsten BögershausenOct 25, 2026
  14. Junio C HamanoOct 25, 2026
  15. 1/1 t1450: use 'mv -f' when overwriting a read-only filetboegi@web.de, Oct 25, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.