git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Arthur Milchior <arthur.milchior@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Misleading error message on a failed `git mv`
Date: Wed, 11 Jan 2023 14:07:16 -0500	[thread overview]
Message-ID: <Y78I5E/BCr1QQ6aL@coredump.intra.peff.net> (raw)
In-Reply-To: <CAEcbrFc=R=3aEwEE56EvZSPSV4+RWFxt=hm7csZ7oBTR8BDQzA@mail.gmail.com>

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

  reply	other threads:[~2023-01-11 19:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  4:19 Misleading error message on a failed `git mv` Arthur Milchior
2023-01-11 19:07 ` Jeff King [this message]
2023-01-11 21:43   ` Torsten Bögershausen
2023-01-11 23:25     ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y78I5E/BCr1QQ6aL@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=arthur.milchior@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).