Add some fancy colors in the test library when terminal supports it.
[gitweb.git] / builtin-mv.c
index 737af350b873e90c787cb49960236fc19b62a3bf..b9446516915c998e41e645a7cc3e28c25ee21dc1 100644 (file)
@@ -22,10 +22,7 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
        for (i = 0; i < count; i++) {
                int length = strlen(result[i]);
                if (length > 0 && result[i][length - 1] == '/') {
-                       char *without_slash = xmalloc(length);
-                       memcpy(without_slash, result[i], length - 1);
-                       without_slash[length - 1] = '\0';
-                       result[i] = without_slash;
+                       result[i] = xmemdupz(result[i], length - 1);
                }
                if (base_name) {
                        const char *last_slash = strrchr(result[i], '/');
@@ -77,7 +74,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
        git_config(git_default_config);
 
-       newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);
+       newfd = hold_locked_index(&lock_file, 1);
        if (read_cache() < 0)
                die("index file corrupt");
 
@@ -273,19 +270,16 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
                for (i = 0; i < added.nr; i++) {
                        const char *path = added.items[i].path;
-                       add_file_to_index(path, verbose);
+                       add_file_to_cache(path, verbose);
                }
 
-               for (i = 0; i < deleted.nr; i++) {
-                       const char *path = deleted.items[i].path;
-                       remove_file_from_cache(path);
-                       cache_tree_invalidate_path(active_cache_tree, path);
-               }
+               for (i = 0; i < deleted.nr; i++)
+                       remove_file_from_cache(deleted.items[i].path);
 
                if (active_cache_changed) {
                        if (write_cache(newfd, active_cache, active_nr) ||
                            close(newfd) ||
-                           commit_lock_file(&lock_file))
+                           commit_locked_index(&lock_file))
                                die("Unable to write new index file");
                }
        }