summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2006-08-09 15:04:16 +0200
committerJunio C Hamano <junkio@cox.net>2006-08-09 14:46:47 -0700
commit5b982f84ee6eb3027e5bdf2e917a0efa48aded6a (patch)
tree59d899f5b77b4f5d9a897218f1d8988376e3940d /merge-recursive.c
parent3d234d0afacd355eb30b330a56bd2efa73bd44d5 (diff)
downloadgit-5b982f84ee6eb3027e5bdf2e917a0efa48aded6a.tar.gz
merge-recur: do not call git-write-tree
Since merge-recur is in C, and uses libgit, it can call the relevant functions directly, without writing the index file. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index f5c0080a51..b8b095179b 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -248,38 +248,34 @@ static int git_merge_trees(int index_only,
return rc;
}
-/*
- * TODO: this can be streamlined by refactoring builtin-write-tree.c
- */
static struct tree *git_write_tree(void)
{
- FILE *fp;
- int rc;
- char buf[41];
- unsigned char sha1[20];
- int ch;
- unsigned i = 0;
+ struct tree *result = NULL;
+
if (cache_dirty) {
+ unsigned i;
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
if (ce_stage(ce))
return NULL;
}
- flush_cache();
- }
- fp = popen("git-write-tree 2>/dev/null", "r");
- while ((ch = fgetc(fp)) != EOF)
- if (i < sizeof(buf)-1 && ch >= '0' && ch <= 'f')
- buf[i++] = ch;
- else
- break;
- rc = pclose(fp);
- if (rc == -1 || WEXITSTATUS(rc))
- return NULL;
- buf[i] = '\0';
- if (get_sha1(buf, sha1) != 0)
- return NULL;
- return lookup_tree(sha1);
+ } else
+ read_cache_from(getenv("GIT_INDEX_FILE"));
+
+ if (!active_cache_tree)
+ active_cache_tree = cache_tree();
+
+ if (!cache_tree_fully_valid(active_cache_tree) &&
+ cache_tree_update(active_cache_tree,
+ active_cache, active_nr, 0, 0) < 0)
+ die("error building trees");
+
+ result = lookup_tree(active_cache_tree->sha1);
+
+ flush_cache();
+ cache_dirty = 0;
+
+ return result;
}
static int save_files_dirs(const unsigned char *sha1,