summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-10-05 21:01:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-05 21:01:55 (GMT)
commit7da656f1e083b065400c4ab92405c6332481eb7a (patch)
tree45b808e3d89448356fc4a591b9b3358034d113b1 /combine-diff.c
parent8e3ec76a20d6abf5dd8ceb3f5f2c157000e4c13e (diff)
parent957876f17d75b5cd0e94b85d3df843bb1e9ae110 (diff)
downloadgit-7da656f1e083b065400c4ab92405c6332481eb7a.zip
git-7da656f1e083b065400c4ab92405c6332481eb7a.tar.gz
git-7da656f1e083b065400c4ab92405c6332481eb7a.tar.bz2
Merge branch 'jk/diff-cc-oidfind-fix'
"log -c --find-object=X" did not work well to find a merge that involves a change to an object X from only one parent. * jk/diff-cc-oidfind-fix: combine-diff: handle --find-object in multitree code path
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/combine-diff.c b/combine-diff.c
index 555b812..9228aeb 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1450,6 +1450,42 @@ static struct combine_diff_path *find_paths_multitree(
return paths_head.next;
}
+static int match_objfind(struct combine_diff_path *path,
+ int num_parent,
+ const struct oidset *set)
+{
+ int i;
+ if (oidset_contains(set, &path->oid))
+ return 1;
+ for (i = 0; i < num_parent; i++) {
+ if (oidset_contains(set, &path->parent[i].oid))
+ return 1;
+ }
+ return 0;
+}
+
+static struct combine_diff_path *combined_objfind(struct diff_options *opt,
+ struct combine_diff_path *paths,
+ int num_parent)
+{
+ struct combine_diff_path *ret = NULL, **tail = &ret;
+ struct combine_diff_path *p = paths;
+
+ while (p) {
+ struct combine_diff_path *next = p->next;
+
+ if (match_objfind(p, num_parent, opt->objfind)) {
+ p->next = NULL;
+ *tail = p;
+ tail = &p->next;
+ } else {
+ free(p);
+ }
+ p = next;
+ }
+
+ return ret;
+}
void diff_tree_combined(const struct object_id *oid,
const struct oid_array *parents,
@@ -1504,10 +1540,10 @@ void diff_tree_combined(const struct object_id *oid,
opt->flags.follow_renames ||
opt->break_opt != -1 ||
opt->detect_rename ||
- (opt->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK) ||
+ (opt->pickaxe_opts &
+ (DIFF_PICKAXE_KINDS_MASK & ~DIFF_PICKAXE_KIND_OBJFIND)) ||
opt->filter;
-
if (need_generic_pathscan) {
/*
* NOTE generic case also handles --stat, as it computes
@@ -1521,6 +1557,9 @@ void diff_tree_combined(const struct object_id *oid,
int stat_opt;
paths = find_paths_multitree(oid, parents, &diffopts);
+ if (opt->pickaxe_opts & DIFF_PICKAXE_KIND_OBJFIND)
+ paths = combined_objfind(opt, paths, num_parent);
+
/*
* show stat against the first parent even
* when doing combined diff.