summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-05-20 11:04:35 -0700
committerJunio C Hamano <gitster@pobox.com>2009-05-20 11:07:07 -0700
commitd11b8d342529a8fe2164ceb563ad9213902d3533 (patch)
tree890ca0413eb098ef8cc8222fa0de72ccd66bee4c /cache-tree.c
parentd00e364de99d51bb76e437820e23cfa820417ec5 (diff)
downloadgit-d11b8d342529a8fe2164ceb563ad9213902d3533.tar.gz
write-tree --ignore-cache-tree
This allows you to discard the cache-tree information before writing the tree out of the index (i.e. it always recomputes the tree object names for all the subtrees). This is only useful as a debug option, so I did not bother documenting it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 37bf35e636..6dd8411945 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -538,28 +538,32 @@ static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *pat
return it;
}
-int write_cache_as_tree(unsigned char *sha1, int missing_ok, const char *prefix)
+int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)
{
int entries, was_valid, newfd;
+ struct lock_file *lock_file;
/*
* We can't free this memory, it becomes part of a linked list
* parsed atexit()
*/
- struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+ lock_file = xcalloc(1, sizeof(struct lock_file));
newfd = hold_locked_index(lock_file, 1);
entries = read_cache();
if (entries < 0)
return WRITE_TREE_UNREADABLE_INDEX;
+ if (flags & WRITE_TREE_IGNORE_CACHE_TREE)
+ cache_tree_free(&(active_cache_tree));
if (!active_cache_tree)
active_cache_tree = cache_tree();
was_valid = cache_tree_fully_valid(active_cache_tree);
-
if (!was_valid) {
+ int missing_ok = flags & WRITE_TREE_MISSING_OK;
+
if (cache_tree_update(active_cache_tree,
active_cache, active_nr,
missing_ok, 0) < 0)