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

Re: Misleading error message on a failed `git mv`

From
Jeff King <peff@peff.net>
Date
Jan 11, 2023, 19:07 UTC
Message-ID
<Y78I5E/BCr1QQ6aL@coredump.intra.peff.net>
In-Reply-To
<CAEcbrFc=R=3aEwEE56EvZSPSV4+RWFxt=hm7csZ7oBTR8BDQzA@mail.gmail.com>
On Wed, Jan 11, 2023 at 05:19:29AM +0100, Arthur Milchior wrote:
Show 10 quoted lines
> Error message is
> 
> fatal: renaming 'file' failed: No such file or directory
> 
> 
> What's different between what you expected and what actually happened?
> 
> The error message seems to indicate that file does not exists. It
> actually exists. The destination directory does not exists and is the
> one that should be mentionned.

I agree the message is not specific as to which case happened, but this is all we get from the kernel's error reporting. We called rename(), the syscall returned ENOENT, and we fed that to strerror() to get "No such file or directory". From the manpage for rename(2):

  ENOENT The link named by oldpath does not exist; or, a directory
	 component in newpath does not exist; or, oldpath or newpath is
	 an empty string.

If we wanted to be more specific, we'd have to go to extra work to diagnose each case. Most tools don't bother. For example:

  $ touch foo
  $ mv foo bar/foo
  mv: cannot move 'foo' to 'bar/foo': No such file or directory
It's quirky, for sure, but it's how most Unix tools behave here.
-Peff
Previous: Arthur MilchiorNext: Torsten Bögershausen
Message 2 of 4 in “Misleading error message on a failed `git mv`”
  1. Arthur MilchiorJan 11, 2023
  2. Jeff KingJan 11, 2023
  3. Torsten BögershausenJan 11, 2023
  4. Andreas SchwabJan 11, 2023

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.