diff --git a/builtin-mv.c b/builtin-mv.c
index fd1e52098174be212c51b957280f38dc6e9c0e48..737af350b873e90c787cb49960236fc19b62a3bf 100644 (file)
--- a/builtin-mv.c
+++ b/builtin-mv.c
*
* Copyright (C) 2006 Johannes Schindelin
*/
*
* Copyright (C) 2006 Johannes Schindelin
*/
-#include <fnmatch.h>
-
#include "cache.h"
#include "builtin.h"
#include "dir.h"
#include "cache.h"
#include "builtin.h"
#include "dir.h"
&& lstat(dst, &st) == 0)
bad = "cannot move directory over file";
else if (src_is_dir) {
&& lstat(dst, &st) == 0)
bad = "cannot move directory over file";
else if (src_is_dir) {
+ const char *src_w_slash = add_slash(src);
+ int len_w_slash = length + 1;
int first, last;
modes[i] = WORKING_DIRECTORY;
int first, last;
modes[i] = WORKING_DIRECTORY;
- first = cache_name_pos(src, length);
+ first = cache_name_pos(src_w_slash, len_w_slash);
if (first >= 0)
if (first >= 0)
- die ("Huh? %s/ is in index?", src);
+ die ("Huh? %.*s is in index?",
+ len_w_slash, src_w_slash);
first = -1 - first;
for (last = first; last < active_nr; last++) {
const char *path = active_cache[last]->name;
first = -1 - first;
for (last = first; last < active_nr; last++) {
const char *path = active_cache[last]->name;
- if (strncmp(path, src, length)
- || path[length] != '/')
+ if (strncmp(path, src_w_slash, len_w_slash))
break;
}
break;
}
+ free((char *)src_w_slash);
if (last - first < 1)
bad = "source directory is empty";
if (last - first < 1)
bad = "source directory is empty";
int j, dst_len;
if (last - first > 0) {
int j, dst_len;
if (last - first > 0) {
- source = realloc(source,
+ source = xrealloc(source,
(count + last - first)
* sizeof(char *));
(count + last - first)
* sizeof(char *));
- destination = realloc(destination,
+ destination = xrealloc(destination,
(count + last - first)
* sizeof(char *));
(count + last - first)
* sizeof(char *));
- modes = realloc(modes,
+ modes = xrealloc(modes,
(count + last - first)
* sizeof(enum update_mode));
}
(count + last - first)
* sizeof(enum update_mode));
}
for (i = 0; i < deleted.nr; i++) {
const char *path = deleted.items[i].path;
remove_file_from_cache(path);
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);
}
if (active_cache_changed) {
}
if (active_cache_changed) {