Skip to content

Commit cd40b05

Browse files
peffgitster
authored andcommitted
mv: improve overwrite warning
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7747164 commit cd40b05

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
@@ -173,7 +173,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
173173
* check both source and destination
174174
*/
175175
if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
176-
warning(_("%s; will overwrite!"), bad);
176+
warning(_("overwriting '%s'"), dst);
177177
bad = NULL;
178178
} else
179179
bad = _("Cannot overwrite");

0 commit comments

Comments
 (0)