mv: improve overwrite warning
authorJeff King <peff@peff.net>
Mon, 12 Dec 2011 21:54:17 +0000 (16:54 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Dec 2011 23:43:38 +0000 (15:43 -0800)
When we try to "git mv" over an existing file, the error
message is fairly informative:

$ git mv one two
fatal: destination exists, source=one, destination=two

When the user forces the overwrite, we give a warning:

$ git mv -f one two
warning: destination exists; will overwrite!

This is less informative, but still sufficient in the simple
rename case, as there is only one rename happening.

But when moving files from one directory to another, it
becomes useless:

$ mkdir three
$ touch one two three/one
$ git add .
$ git mv one two three
fatal: destination exists, source=one, destination=three/one
$ git mv -f one two three
warning: destination exists; will overwrite!

The first message is helpful, but the second one gives us no
clue about what was overwritten. Let's mention the name of
the destination file:

$ git mv -f one two three
warning: overwriting 'three/one'

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mv.c
index 177e5437813b4ed65ed4b984d2d6ae4d0dbd43cd..4a8374f63d8a55593309a42967a740201de6a62a 100644 (file)
@@ -173,7 +173,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                 * check both source and destination
                                 */
                                if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
-                                       warning(_("%s; will overwrite!"), bad);
+                                       warning(_("overwriting '%s'"), dst);
                                        bad = NULL;
                                } else
                                        bad = _("Cannot overwrite");