X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=builtin-mv.c;h=1b20028c67dec2f9954cb107620bd863b4b3a264;hb=1d7367dce7b55cbb1804c4863c56bd20ab12bda8;hp=8b81d4b51d78bb2aa49430102ab585afce9cccdf;hpb=b11cf09043f18b368ec0d988f064ea21247c843d;p=~andy%2Fgit diff --git a/builtin-mv.c b/builtin-mv.c index 8b81d4b51..1b20028c6 100644 --- a/builtin-mv.c +++ b/builtin-mv.c @@ -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;