Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2018-07-01 04:25:00 +0300
committerJunio C Hamano <gitster@pobox.com>2018-07-11 19:38:36 +0300
commite1f8694f3394caf3d3cd57c6c7593f0b0cdb1f9e (patch)
treedd07179f9af2ebd29a518d3553ea061ceb099b77 /read-cache.c
parent92702392cefdbd66ca593fa909540230ef9e005e (diff)
merge-recursive: fix assumption that head tree being merged is HEAD
`git merge-recursive` does a three-way merge between user-specified trees base, head, and remote. Since the user is allowed to specify head, we can not necesarily assume that head == HEAD. Modify index_has_changes() to take an extra argument specifying the tree to compare against. If NULL, it will compare to HEAD. We then use this from merge-recursive to make sure we compare to the user-specified head. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/read-cache.c b/read-cache.c
index f333a517f7..639c1fffa0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1986,22 +1986,26 @@ int unmerged_index(const struct index_state *istate)
return 0;
}
-int index_has_changes(const struct index_state *istate, struct strbuf *sb)
+int index_has_changes(const struct index_state *istate,
+ struct tree *tree,
+ struct strbuf *sb)
{
- struct object_id head;
+ struct object_id cmp;
int i;
if (istate != &the_index) {
BUG("index_has_changes cannot yet accept istate != &the_index; do_diff_cache needs updating first.");
}
- if (!get_oid_tree("HEAD", &head)) {
+ if (tree)
+ cmp = tree->object.oid;
+ if (tree || !get_oid_tree("HEAD", &cmp)) {
struct diff_options opt;
diff_setup(&opt);
opt.flags.exit_with_status = 1;
if (!sb)
opt.flags.quick = 1;
- do_diff_cache(&head, &opt);
+ do_diff_cache(&cmp, &opt);
diffcore_std(&opt);
for (i = 0; sb && i < diff_queued_diff.nr; i++) {
if (i)