From: Junio C Hamano Date: Fri, 14 Sep 2007 08:19:30 +0000 (-0700) Subject: Merge branch 'jc/cachetree' into cr/reset X-Git-Tag: v1.5.4-rc0~434^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/58f6fb53dd1104559f6f5507562a975c0ff079af?hp=-c Merge branch 'jc/cachetree' into cr/reset * jc/cachetree: Simplify cache API git-format-patch --in-reply-to: accept with angle brackets git-add -u: do not barf on type changes Remove duplicate note about removing commits with git-filter-branch git-clone: improve error message if curl program is missing or not executable git.el: Allow the add and remove commands to be applied to ignored files. git.el: Allow selecting whether to display uptodate/unknown/ignored files. git.el: Keep the status buffer sorted by filename. hooks--update: Explicitly check for all zeros for a deleted ref. --- 58f6fb53dd1104559f6f5507562a975c0ff079af diff --combined read-cache.c index 536f4d0875,d82a99a915..2e40a34420 --- a/read-cache.c +++ b/read-cache.c @@@ -346,6 -346,7 +346,7 @@@ int remove_file_from_index(struct index int pos = index_name_pos(istate, path, strlen(path)); if (pos < 0) pos = -pos-1; + cache_tree_invalidate_path(istate->cache_tree, path); while (pos < istate->cache_nr && !strcmp(istate->cache[pos]->name, path)) remove_index_entry_at(istate, pos); return 0; @@@ -430,35 -431,9 +431,34 @@@ int add_file_to_index(struct index_stat die("unable to add %s to index",path); if (verbose) printf("add '%s'\n", path); - cache_tree_invalidate_path(istate->cache_tree, path); return 0; } +struct cache_entry *make_cache_entry(unsigned int mode, + const unsigned char *sha1, const char *path, int stage, + int refresh) +{ + int size, len; + struct cache_entry *ce; + + if (!verify_path(path)) + return NULL; + + len = strlen(path); + size = cache_entry_size(len); + ce = xcalloc(1, size); + + hashcpy(ce->sha1, sha1); + memcpy(ce->name, path, len); + ce->ce_flags = create_ce_flags(len, stage); + ce->ce_mode = create_ce_mode(mode); + + if (refresh) + return refresh_cache_entry(ce, 0); + + return ce; +} + int ce_same_name(struct cache_entry *a, struct cache_entry *b) { int len = ce_namelen(a); @@@ -698,6 -673,7 +698,7 @@@ static int add_index_entry_with_check(s int ok_to_replace = option & ADD_CACHE_OK_TO_REPLACE; int skip_df_check = option & ADD_CACHE_SKIP_DFCHECK; + cache_tree_invalidate_path(istate->cache_tree, ce->name); pos = index_name_pos(istate, ce->name, ntohs(ce->ce_flags)); /* existing match? Just replace it. */