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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 11, 2023 at 05:19:29AM +0100, Arthur Milchior wrote:

> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux