From: Jeff King Date: Mon, 12 Dec 2011 07:51:36 +0000 (-0500) Subject: mv: make non-directory destination error more clear X-Git-Tag: v1.7.8.2~15^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=77471646d3d87691b4bcf11682945e6ccc27f9e3;p=git.git 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] ... [...] 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 ( | ... ) 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/mv.c b/builtin/mv.c index 449f30aac..177e54378 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -90,7 +90,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) destination = copy_pathspec(dest_path[0], argv, argc, 1); } else { if (argc != 1) - usage_with_options(builtin_mv_usage, builtin_mv_options); + die("destination '%s' is not a directory", dest_path[0]); destination = dest_path; }