summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-09-29 16:49:38 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-09-29 16:49:38 -0700
commit35ca3e538d2e36c528ff5382a0e3cca35b46c6ed (patch)
treeaa74aa79c8c4c9510eacce8747e80a3454a30e2e
parentMerge branch 'js/git-gui-commit-gpgsign' into maint (diff)
parentpatch-ids: refuse to compute patch-id for merge commit (diff)
downloadtgif-35ca3e538d2e36c528ff5382a0e3cca35b46c6ed.tar.xz
Merge branch 'jk/patch-ids-no-merges' into maint
"git log --cherry-pick" used to include merge commits as candidates to be matched up with other commits, resulting a lot of wasted time. The patch-id generation logic has been updated to ignore merges to avoid the wastage. * jk/patch-ids-no-merges: patch-ids: refuse to compute patch-id for merge commit patch-ids: turn off rename detection
-rw-r--r--patch-ids.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/patch-ids.c b/patch-ids.c
index 082412aca6..ce285c2e0c 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -4,9 +4,18 @@
#include "sha1-lookup.h"
#include "patch-ids.h"
+static int patch_id_defined(struct commit *commit)
+{
+ /* must be 0 or 1 parents */
+ return !commit->parents || !commit->parents->next;
+}
+
int commit_patch_id(struct commit *commit, struct diff_options *options,
unsigned char *sha1, int diff_header_only)
{
+ if (!patch_id_defined(commit))
+ return -1;
+
if (commit->parents)
diff_tree_sha1(commit->parents->item->object.oid.hash,
commit->object.oid.hash, "", options);
@@ -45,6 +54,7 @@ int init_patch_ids(struct patch_ids *ids)
{
memset(ids, 0, sizeof(*ids));
diff_setup(&ids->diffopts);
+ ids->diffopts.detect_rename = 0;
DIFF_OPT_SET(&ids->diffopts, RECURSIVE);
diff_setup_done(&ids->diffopts);
hashmap_init(&ids->patches, (hashmap_cmp_fn)patch_id_cmp, 256);
@@ -76,6 +86,9 @@ struct patch_id *has_commit_patch_id(struct commit *commit,
{
struct patch_id patch;
+ if (!patch_id_defined(commit))
+ return NULL;
+
memset(&patch, 0, sizeof(patch));
if (init_patch_id_entry(&patch, commit, ids))
return NULL;
@@ -88,6 +101,9 @@ struct patch_id *add_commit_patch_id(struct commit *commit,
{
struct patch_id *key = xcalloc(1, sizeof(*key));
+ if (!patch_id_defined(commit))
+ return NULL;
+
if (init_patch_id_entry(key, commit, ids)) {
free(key);
return NULL;