summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4eb0346)
raw | patch | inline | side by side (parent: 4eb0346)
author | Thomas Rast <trast@student.ethz.ch> | |
Tue, 6 Dec 2011 17:43:37 +0000 (18:43 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 6 Dec 2011 22:57:36 +0000 (14:57 -0800) |
We'll need to safely create or update the cache-tree data of the_index
from other places. While at it, give it an argument that lets us
silence the messages produced by unmerged entries (which prevent it
from working).
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
from other places. While at it, give it an argument that lets us
silence the messages produced by unmerged entries (which prevent it
from working).
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c | patch | blob | history | |
cache-tree.c | patch | blob | history | |
cache-tree.h | patch | blob | history | |
merge-recursive.c | patch | blob | history | |
test-dump-cache-tree.c | patch | blob | history |
diff --git a/builtin/commit.c b/builtin/commit.c
index 8f2bebecf313a0e4b742f9327ec178c7e3547dd2..4f782a33f1dde5c82d7da5f1051083a743e00ddd 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
*/
discard_cache();
read_cache_from(index_file);
- if (!active_cache_tree)
- active_cache_tree = cache_tree();
- if (cache_tree_update(active_cache_tree,
- active_cache, active_nr, 0, 0) < 0) {
+ if (update_main_cache_tree(0)) {
error(_("Error building trees"));
return 0;
}
diff --git a/cache-tree.c b/cache-tree.c
index f755590da827234830d8b4359720cfbfd87a3dea..8de39590d57e14d08ee4d04b74965191aa905b29 100644 (file)
--- a/cache-tree.c
+++ b/cache-tree.c
}
static int verify_cache(struct cache_entry **cache,
- int entries)
+ int entries, int silent)
{
int i, funny;
for (i = 0; i < entries; i++) {
struct cache_entry *ce = cache[i];
if (ce_stage(ce) || (ce->ce_flags & CE_INTENT_TO_ADD)) {
+ if (silent)
+ return -1;
if (10 < ++funny) {
fprintf(stderr, "...\n");
break;
struct cache_entry **cache,
int entries,
int missing_ok,
- int dryrun)
+ int dryrun,
+ int silent)
{
int i;
- i = verify_cache(cache, entries);
+ i = verify_cache(cache, entries, silent);
if (i)
return i;
i = update_one(it, cache, entries, "", 0, missing_ok, dryrun);
if (cache_tree_update(active_cache_tree,
active_cache, active_nr,
- missing_ok, 0) < 0)
+ missing_ok, 0, 0) < 0)
return WRITE_TREE_UNMERGED_INDEX;
if (0 <= newfd) {
if (!write_cache(newfd, active_cache, active_nr) &&
return it->entry_count;
return 0;
}
+
+int update_main_cache_tree (int silent)
+{
+ if (!the_index.cache_tree)
+ the_index.cache_tree = cache_tree();
+ return cache_tree_update(the_index.cache_tree,
+ the_index.cache, the_index.cache_nr, 0, 0, silent);
+}
diff --git a/cache-tree.h b/cache-tree.h
index 3df641f59311f43aa951a2cdfa9f110b97b13a45..0ec0b2a159dfd352ca621322a9ce3715328ab2d0 100644 (file)
--- a/cache-tree.h
+++ b/cache-tree.h
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
int cache_tree_fully_valid(struct cache_tree *);
-int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int);
+int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int, int);
+
+int update_main_cache_tree(int);
/* bitmasks to write_cache_as_tree flags */
#define WRITE_TREE_MISSING_OK 1
diff --git a/merge-recursive.c b/merge-recursive.c
index cc664c39b66b0bb499dec13a22880a6096423fa6..e22a5195f65cac2872933b668180ceb3c80d3e7c 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
if (!cache_tree_fully_valid(active_cache_tree) &&
cache_tree_update(active_cache_tree,
- active_cache, active_nr, 0, 0) < 0)
+ active_cache, active_nr, 0, 0, 0) < 0)
die("error building trees");
result = lookup_tree(active_cache_tree->sha1);
diff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c
index 1f73f1ea7dfa6a14dedf384c99751e86c8121ff4..e6c292385f9492ab8a58a693e854025a11b9b045 100644 (file)
--- a/test-dump-cache-tree.c
+++ b/test-dump-cache-tree.c
struct cache_tree *another = cache_tree();
if (read_cache() < 0)
die("unable to read index file");
- cache_tree_update(another, active_cache, active_nr, 0, 1);
+ cache_tree_update(another, active_cache, active_nr, 0, 1, 0);
return dump_cache_tree(active_cache_tree, another, "");
}