projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
index: make the index file format extensible.
[git.git]
/
update-index.c
diff --git
a/update-index.c
b/update-index.c
index
ce1db38
..
d6d3295
100644
(file)
--- a/
update-index.c
+++ b/
update-index.c
@@
-6,6
+6,7
@@
#include "cache.h"
#include "strbuf.h"
#include "quote.h"
#include "cache.h"
#include "strbuf.h"
#include "quote.h"
+#include "cache-tree.h"
/*
* Default to not allowing changes to the list of files. The
/*
* Default to not allowing changes to the list of files. The
@@
-70,6
+71,7
@@
static int mark_valid(const char *path)
active_cache[pos]->ce_flags &= ~htons(CE_VALID);
break;
}
active_cache[pos]->ce_flags &= ~htons(CE_VALID);
break;
}
+ cache_tree_invalidate_path(active_cache_tree, path);
active_cache_changed = 1;
return 0;
}
active_cache_changed = 1;
return 0;
}
@@
-83,6
+85,12
@@
static int add_file_to_cache(const char *path)
struct stat st;
status = lstat(path, &st);
struct stat st;
status = lstat(path, &st);
+
+ /* We probably want to do this in remove_file_from_cache() and
+ * add_cache_entry() instead...
+ */
+ cache_tree_invalidate_path(active_cache_tree, path);
+
if (status < 0 || S_ISDIR(st.st_mode)) {
/* When we used to have "path" and now we want to add
* "path/file", we need a way to remove "path" before
if (status < 0 || S_ISDIR(st.st_mode)) {
/* When we used to have "path" and now we want to add
* "path/file", we need a way to remove "path" before
@@
-114,8
+122,7
@@
static int add_file_to_cache(const char *path)
namelen = strlen(path);
size = cache_entry_size(namelen);
namelen = strlen(path);
size = cache_entry_size(namelen);
- ce = xmalloc(size);
- memset(ce, 0, size);
+ ce = xcalloc(1, size);
memcpy(ce->name, path, namelen);
ce->ce_flags = htons(namelen);
fill_stat_cache_info(ce, &st);
memcpy(ce->name, path, namelen);
ce->ce_flags = htons(namelen);
fill_stat_cache_info(ce, &st);
@@
-312,8
+319,7
@@
static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
len = strlen(path);
size = cache_entry_size(len);
len = strlen(path);
size = cache_entry_size(len);
- ce = xmalloc(size);
- memset(ce, 0, size);
+ ce = xcalloc(1, size);
memcpy(ce->sha1, sha1, 20);
memcpy(ce->name, path, len);
memcpy(ce->sha1, sha1, 20);
memcpy(ce->name, path, len);
@@
-327,6
+333,7
@@
static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
return error("%s: cannot add to the index - missing --add option?",
path);
report("add '%s'", path);
return error("%s: cannot add to the index - missing --add option?",
path);
report("add '%s'", path);
+ cache_tree_invalidate_path(active_cache_tree, path);
return 0;
}
return 0;
}
@@
-351,6
+358,7
@@
static int chmod_path(int flip, const char *path)
default:
return -1;
}
default:
return -1;
}
+ cache_tree_invalidate_path(active_cache_tree, path);
active_cache_changed = 1;
return 0;
}
active_cache_changed = 1;
return 0;
}
@@
-369,6
+377,7
@@
static void update_one(const char *path, const char *prefix, int prefix_length)
die("Unable to mark file %s", path);
return;
}
die("Unable to mark file %s", path);
return;
}
+ cache_tree_invalidate_path(active_cache_tree, path);
if (force_remove) {
if (remove_file_from_cache(p))
if (force_remove) {
if (remove_file_from_cache(p))
@@
-444,6
+453,7
@@
static void read_index_info(int line_termination)
free(path_name);
continue;
}
free(path_name);
continue;
}
+ cache_tree_invalidate_path(active_cache_tree, path_name);
if (!mode) {
/* mode == 0 means there is no such path -- remove */
if (!mode) {
/* mode == 0 means there is no such path -- remove */
@@
-577,9
+587,11
@@
int main(int argc, const char **argv)
break;
}
if (!strcmp(path, "--index-info")) {
break;
}
if (!strcmp(path, "--index-info")) {
+ if (i != argc - 1)
+ die("--index-info must be at the end");
allow_add = allow_replace = allow_remove = 1;
read_index_info(line_termination);
allow_add = allow_replace = allow_remove = 1;
read_index_info(line_termination);
-
continue
;
+
break
;
}
if (!strcmp(path, "--ignore-missing")) {
not_new = 1;
}
if (!strcmp(path, "--ignore-missing")) {
not_new = 1;