t7502: honor SHELL_PATH
[gitweb.git] / builtin-mv.c
index a3f9ad174492827e42f2854287fab19915d8ef76..5530e11b89c2c05c95c8ab1e82999eec0fdcc4c5 100644 (file)
@@ -81,7 +81,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
        struct path_list deleted = {NULL, 0, 0, 0};
        struct path_list changed = {NULL, 0, 0, 0};
 
-       git_config(git_default_config);
+       git_config(git_default_config, NULL);
 
        newfd = hold_locked_index(&lock_file, 1);
        if (read_cache() < 0)
@@ -164,7 +164,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                }
 
                                dst = add_slash(dst);
-                               dst_len = strlen(dst) - 1;
+                               dst_len = strlen(dst);
 
                                for (j = 0; j < last - first; j++) {
                                        const char *path =
@@ -172,7 +172,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                        source[argc + j] = path;
                                        destination[argc + j] =
                                                prefix_path(dst, dst_len,
-                                                       path + length);
+                                                       path + length + 1);
                                        modes[argc + j] = INDEX;
                                }
                                argc += last - first;
@@ -256,7 +256,8 @@ 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_cache(path, verbose);
+                       if (add_file_to_cache(path, verbose ? ADD_CACHE_VERBOSE : 0))
+                               die("updating index entries failed");
                }
 
                for (i = 0; i < deleted.nr; i++)
@@ -264,7 +265,6 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
                if (active_cache_changed) {
                        if (write_cache(newfd, active_cache, active_nr) ||
-                           close(newfd) ||
                            commit_locked_index(&lock_file))
                                die("Unable to write new index file");
                }