X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=update-index.c;h=fbccc4a67b95dae4ff5c4f9bb02fc28e8887bc67;hb=fb6a9f93d39e4e5fdb83673a927f71a34e9fb7c0;hp=5854d11fd9d96536c7001dec9c4f734dde18c674;hpb=4868f3729acce2aa9512ded7179a895cc50f64c8;p=git.git diff --git a/update-index.c b/update-index.c index 5854d11f..fbccc4a6 100644 --- a/update-index.c +++ b/update-index.c @@ -6,6 +6,7 @@ #include "cache.h" #include "strbuf.h" #include "quote.h" +#include "cache-tree.h" #include "tree-walk.h" /* @@ -51,6 +52,7 @@ static int mark_valid(const char *path) active_cache[pos]->ce_flags &= ~htons(CE_VALID); break; } + cache_tree_invalidate_path(active_cache_tree, path); active_cache_changed = 1; return 0; } @@ -64,6 +66,12 @@ static int add_file_to_cache(const char *path) 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 @@ -145,6 +153,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); + cache_tree_invalidate_path(active_cache_tree, path); return 0; } @@ -169,6 +178,7 @@ static void chmod_path(int flip, const char *path) default: goto fail; } + cache_tree_invalidate_path(active_cache_tree, path); active_cache_changed = 1; report("chmod %cx '%s'", flip, path); return; @@ -176,7 +186,7 @@ static void chmod_path(int flip, const char *path) die("git-update-index: cannot chmod %cx '%s'", flip, path); } -static struct cache_file cache_file; +static struct lock_file lock_file; static void update_one(const char *path, const char *prefix, int prefix_length) { @@ -190,6 +200,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length) die("Unable to mark file %s", path); goto free_return; } + cache_tree_invalidate_path(active_cache_tree, path); if (force_remove) { if (remove_file_from_cache(p)) @@ -268,6 +279,7 @@ static void read_index_info(int line_termination) free(path_name); continue; } + cache_tree_invalidate_path(active_cache_tree, path_name); if (!mode) { /* mode == 0 means there is no such path -- remove */ @@ -374,6 +386,7 @@ static int unresolve_one(const char *path) goto free_return; } + cache_tree_invalidate_path(active_cache_tree, path); remove_file_from_cache(path); if (add_cache_entry(ce_2, ADD_CACHE_OK_TO_ADD)) { error("%s: cannot add our version to the index.", path); @@ -476,9 +489,9 @@ int main(int argc, const char **argv) git_config(git_default_config); - newfd = hold_index_file_for_update(&cache_file, get_index_file()); + newfd = hold_lock_file_for_update(&lock_file, get_index_file()); if (newfd < 0) - die("unable to create new cachefile"); + die("unable to create new index file"); entries = read_cache(); if (entries < 0) @@ -632,8 +645,8 @@ int main(int argc, const char **argv) finish: if (active_cache_changed) { if (write_cache(newfd, active_cache, active_nr) || - commit_index_file(&cache_file)) - die("Unable to write new cachefile"); + commit_lock_file(&lock_file)) + die("Unable to write new index file"); } return has_errors ? 1 : 0;