Skip to contentSkip to conversation

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

DISCUSSION Patrick Lehner 2 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 8 lines · Patrick Lehner

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`

Quoted 6 lines

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.

#2 lore raw

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.

Quoted 26 lines · Junio C Hamano
Quoted 8 lines · Patrick Lehner

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`

Quoted 6 lines

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.

#3 lore raw
Quoted 2 lines · Patrick Lehner

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.

#4 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 2 lines · Patrick Lehner

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)?

Quoted 5 lines

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