threads / discuss / 32123

`git mv` has ambiguous error message for non-existing target

Subject: `git mv` has ambiguous error message for non-existing target

## tl;dr

5 messages between Nov 15, 2012 and Nov 19, 2012.

replies: 4people: 2as markdown or json

Patrick Lehner· Nov 15, 2012, 18:54 UTC · lore
Hey guys,

as was brought up on #github today, the "git mv" command has a bit of a little-helping output message when the target directory (or any intermediate directories) dont exist.

To reproduce:
- cd into a git repo
- assuming "filea.txt" is an existing file in the CWD, and "dirb" is 
neither a file nor a directory in the CWD, use the command "git mv 
filea.txt dirb/filea.txt"
- this will produce an error message like `fatal: renaming 'filea.sh' 
failed: No such file or directory`

It does not mention that the problem is, in fact, the target directory not existing. This seems to be mostly a problem for users unfamiliar with bash/*nix console commands. Although it is documented that git mv will not create intermediate folders (which is fine, because neither does mv), the error message might lead to believe a problem exists with the source file.

Expanding the error message to "No such file or directory: 'dirb/' " would probably clear this up.

Best regards and thanks to anyone who could improve this, Patrick

Junio C Hamano· Nov 16, 2012, 01:34 UTC · re: Patrick Lehner · lore

Re: `git mv` has ambiguous error message for non-existing target

Patrick Lehner <lehner.patrick@gmx.de> writes:
Show 14 quoted lines
> To reproduce:
> - cd into a git repo
> - assuming "filea.txt" is an existing file in the CWD, and "dirb" is
> neither a file nor a directory in the CWD, use the command "git mv
> filea.txt dirb/filea.txt"
> - this will produce an error message like `fatal: renaming 'filea.sh'
> failed: No such file or directory`
>
> It does not mention that the problem is, in fact, the target directory
> not existing. This seems to be mostly a problem for users unfamiliar
> with bash/*nix console commands. Although it is documented that git mv
> will not create intermediate folders (which is fine, because neither
> does mv), the error message might lead to believe a problem exists
> with the source file.
    $ rm -fr xxx
    $ >yyy
    $ mv yyy xxx/yyy
    mv: cannot move `yyy' to `xxx/yyy': No such file or directory

It doesn't mention that the problem is with 'xxx' and not 'yyy' either.

Patrick Lehner· Nov 16, 2012, 07:10 UTC · re: Junio C Hamano · lore

Re: `git mv` has ambiguous error message for non-existing target

But just because mv's error essage isnt very good, does that mean git mv's error message mustn't be better? That would strike me as an odd bit of reasoning.

On Fr 16 Nov 2012 02:34:32 CET, Junio C Hamano wrote:
Show 26 quoted lines
> Patrick Lehner <lehner.patrick@gmx.de> writes:
>
>> To reproduce:
>> - cd into a git repo
>> - assuming "filea.txt" is an existing file in the CWD, and "dirb" is
>> neither a file nor a directory in the CWD, use the command "git mv
>> filea.txt dirb/filea.txt"
>> - this will produce an error message like `fatal: renaming 'filea.sh'
>> failed: No such file or directory`
>>
>> It does not mention that the problem is, in fact, the target directory
>> not existing. This seems to be mostly a problem for users unfamiliar
>> with bash/*nix console commands. Although it is documented that git mv
>> will not create intermediate folders (which is fine, because neither
>> does mv), the error message might lead to believe a problem exists
>> with the source file.
>
>      $ rm -fr xxx
>      $ >yyy
>      $ mv yyy xxx/yyy
>      mv: cannot move `yyy' to `xxx/yyy': No such file or directory
>
> It doesn't mention that the problem is with 'xxx' and not 'yyy'
> either.
>
>
Junio C Hamano· Nov 17, 2012, 19:35 UTC · re: Patrick Lehner · lore

Re: `git mv` has ambiguous error message for non-existing target

Patrick Lehner <lehner.patrick@gmx.de> writes:
> But just because mv's error essage isnt very good, does that mean git
> mv's error message mustn't be better?

Did I say the error message from 'mv' was not very good in the message you are responding to (by the way, this is why you should never top-post when you are responding to a message on this list)?

I meant to say that the message from 'mv' is good enough, so is the one given by 'git mv'.

I wouldn't reject a patch that updates our message to something more informative without looking at it, though.

Patrick Lehner· Nov 19, 2012, 21:07 UTC · re: Junio C Hamano · lore

Re: `git mv` has ambiguous error message for non-existing target

On Sa 17 Nov 2012 20:35:09 CET, Junio C Hamano wrote:
Show 14 quoted lines
> Patrick Lehner <lehner.patrick@gmx.de> writes:
>
>> But just because mv's error essage isnt very good, does that mean git
>> mv's error message mustn't be better?
>
> Did I say the error message from 'mv' was not very good in the
> message you are responding to (by the way, this is why you should
> never top-post when you are responding to a message on this list)?
>
> I meant to say that the message from 'mv' is good enough, so is the
> one given by 'git mv'.
>
> I wouldn't reject a patch that updates our message to something more
> informative without looking at it, though.

I apologize for top-posting -- I don't usually use mailing lists and am not aware of the usual netiquette.

And yes, I did interpret a bit more into your reply than was there.

I wouldn't call the 'mv' error message "good enough" in this case, but very well, opinions may very well differ. Unfortunately, I have no time to get into the git code and contribution guidelines, so I cannot submit a patch myself. I would appreciate if someone else who shares my sentiment and knows their way around the git source a bit could find the time to add this :)

Regards, Patrick

← back to recent threads