Skip to content

Commit 7747164

Browse files
peffgitster
authored andcommitted
mv: make non-directory destination error more clear
If you try to "git mv" multiple files onto another non-directory file, you confusingly get the "usage" message: $ touch one two three $ git add . $ git mv one two three usage: git mv [options] <source>... <destination> [...] From the user's perspective, that makes no sense. They just gave parameters that exactly match that usage! This behavior dates back to the original C version of "git mv", which had a usage message like: usage: git mv (<source> <destination> | <source>... <destination>) This was slightly less confusing, because it at least mentions that there are two ways to invoke (but it still isn't clear why what the user provided doesn't work). Instead, let's show an error message like: $ git mv one two three fatal: destination 'three' is not a directory We could leave the usage message in place, too, but it doesn't actually help here. It contains no hints that there are two forms, nor that multi-file form requires that the endpoint be a directory. So it just becomes useless noise that distracts from the real error. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 07b8738 commit 7747164

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/mv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
9090
destination = copy_pathspec(dest_path[0], argv, argc, 1);
9191
} else {
9292
if (argc != 1)
93-
usage_with_options(builtin_mv_usage, builtin_mv_options);
93+
die("destination '%s' is not a directory", dest_path[0]);
9494
destination = dest_path;
9595
}
9696

0 commit comments

Comments
 (0)