summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-02-01 12:05:00 -0800
committerEdward Thomson <ethomson@microsoft.com>2014-02-03 19:56:34 -0800
commitc0b10c25e02c6922276567600988fb2b85aeede1 (patch)
tree423e6a5a50bfe3ff36c4f73e73ef6a1696aaefa5
parentbb13d39162b0416585b34f18e9072fc4364d2655 (diff)
downloadlibgit2-c0b10c25e02c6922276567600988fb2b85aeede1.tar.gz
Merge wd validation tests against index not HEAD
Validating the workdir should not compare HEAD to working directory - this is both inefficient (as it ignores the cache) and incorrect. If we had legitimately allowed changes in the index (identical to the merge result) then comparing HEAD to workdir would reject these changes as different. Further, this will identify files that were filtered strangely as modified, while testing with the cache would prevent this. Also, it's stupid slow.
-rw-r--r--src/merge.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/merge.c b/src/merge.c
index 20cfc0e23..2ae02e54d 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2330,7 +2330,7 @@ done:
static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_index *index_new, git_vector *merged_paths)
{
- git_tree *head_tree = NULL;
+ git_index *index_repo = NULL;
git_diff *wd_diff_list = NULL;
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
int error = 0;
@@ -2341,9 +2341,6 @@ static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_inde
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
- if ((error = git_repository_head_tree(&head_tree, repo)) < 0)
- goto done;
-
/* Workdir changes may exist iff they do not conflict with changes that
* will be applied by the merge (including conflicts). Ensure that there
* are no changes in the workdir to these paths.
@@ -2351,13 +2348,13 @@ static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_inde
opts.pathspec.count = merged_paths->length;
opts.pathspec.strings = (char **)merged_paths->contents;
- if ((error = git_diff_tree_to_workdir(&wd_diff_list, repo, head_tree, &opts)) < 0)
+ if ((error = git_diff_index_to_workdir(&wd_diff_list, repo, index_repo, &opts)) < 0)
goto done;
*conflicts = wd_diff_list->deltas.length;
done:
- git_tree_free(head_tree);
+ git_index_free(index_repo);
git_diff_free(wd_diff_list);
return error;