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>
This commit is contained in:
parent
3d234d0afa
commit
5b982f84ee
@ -248,38 +248,34 @@ static int git_merge_trees(int index_only,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: this can be streamlined by refactoring builtin-write-tree.c
|
|
||||||
*/
|
|
||||||
static struct tree *git_write_tree(void)
|
static struct tree *git_write_tree(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
struct tree *result = NULL;
|
||||||
int rc;
|
|
||||||
char buf[41];
|
|
||||||
unsigned char sha1[20];
|
|
||||||
int ch;
|
|
||||||
unsigned i = 0;
|
|
||||||
if (cache_dirty) {
|
if (cache_dirty) {
|
||||||
|
unsigned i;
|
||||||
for (i = 0; i < active_nr; i++) {
|
for (i = 0; i < active_nr; i++) {
|
||||||
struct cache_entry *ce = active_cache[i];
|
struct cache_entry *ce = active_cache[i];
|
||||||
if (ce_stage(ce))
|
if (ce_stage(ce))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
flush_cache();
|
} else
|
||||||
}
|
read_cache_from(getenv("GIT_INDEX_FILE"));
|
||||||
fp = popen("git-write-tree 2>/dev/null", "r");
|
|
||||||
while ((ch = fgetc(fp)) != EOF)
|
if (!active_cache_tree)
|
||||||
if (i < sizeof(buf)-1 && ch >= '0' && ch <= 'f')
|
active_cache_tree = cache_tree();
|
||||||
buf[i++] = ch;
|
|
||||||
else
|
if (!cache_tree_fully_valid(active_cache_tree) &&
|
||||||
break;
|
cache_tree_update(active_cache_tree,
|
||||||
rc = pclose(fp);
|
active_cache, active_nr, 0, 0) < 0)
|
||||||
if (rc == -1 || WEXITSTATUS(rc))
|
die("error building trees");
|
||||||
return NULL;
|
|
||||||
buf[i] = '\0';
|
result = lookup_tree(active_cache_tree->sha1);
|
||||||
if (get_sha1(buf, sha1) != 0)
|
|
||||||
return NULL;
|
flush_cache();
|
||||||
return lookup_tree(sha1);
|
cache_dirty = 0;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int save_files_dirs(const unsigned char *sha1,
|
static int save_files_dirs(const unsigned char *sha1,
|
||||||
|
Loading…
Reference in New Issue
Block a user