X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-mv.c;h=b9446516915c998e41e645a7cc3e28c25ee21dc1;hb=182af8343c307436bb5364309aa6d4d46fa5911d;hp=737af350b873e90c787cb49960236fc19b62a3bf;hpb=27ebd6e0443bdd795869f598ecebc9eadd64a26c;p=git.git diff --git a/builtin-mv.c b/builtin-mv.c index 737af350b..b94465169 100644 --- a/builtin-mv.c +++ b/builtin-mv.c @@ -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"); } }