Code

Merge branch 'ne/maint-1.6.0-diff-tree-t-r-show-directory'
[git.git] / builtin-mv.c
index 01270fefdfb04ed27379b1ca761a811b929ce887..68f47384dc1cc6404d4db73b6dbea8bceab38df9 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);
 }
@@ -72,7 +68,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
        if (read_cache() < 0)
                die("index file corrupt");
 
-       argc = parse_options(argc, argv, builtin_mv_options, builtin_mv_usage, 0);
+       argc = parse_options(argc, argv, prefix, builtin_mv_options,
+                            builtin_mv_usage, 0);
        if (--argc < 1)
                usage_with_options(builtin_mv_usage, builtin_mv_options);