]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-mv.c
Fix some printf format warnings
[thirdparty/git.git] / builtin-mv.c
index 8b81d4b51d78bb2aa49430102ab585afce9cccdf..1b20028c67dec2f9954cb107620bd863b4b3a264 100644 (file)
@@ -24,14 +24,10 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
        result[count] = NULL;
        for (i = 0; i < count; i++) {
                int length = strlen(result[i]);
-               if (length > 0 && result[i][length - 1] == '/') {
+               if (length > 0 && is_dir_sep(result[i][length - 1]))
                        result[i] = xmemdupz(result[i], length - 1);
-               }
-               if (base_name) {
-                       const char *last_slash = strrchr(result[i], '/');
-                       if (last_slash)
-                               result[i] = last_slash + 1;
-               }
+               if (base_name)
+                       result[i] = basename((char *)result[i]);
        }
        return get_pathspec(prefix, result);
 }
@@ -57,7 +53,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
        int verbose = 0, show_only = 0, force = 0, ignore_errors = 0;
        struct option builtin_mv_options[] = {
                OPT__DRY_RUN(&show_only),
-               OPT_BOOLEAN('f', NULL, &force, "force move/rename even if target exists"),
+               OPT_BOOLEAN('f', "force", &force, "force move/rename even if target exists"),
                OPT_BOOLEAN('k', NULL, &ignore_errors, "skip move/rename errors"),
                OPT_END(),
        };
@@ -209,7 +205,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                        printf("Renaming %s to %s\n", src, dst);
                if (!show_only && mode != INDEX &&
                                rename(src, dst) < 0 && !ignore_errors)
-                       die ("renaming %s failed: %s", src, strerror(errno));
+                       die_errno ("renaming '%s' failed", src);
 
                if (mode == WORKING_DIRECTORY)
                        continue;