Skip to content

Commit 35ca3e5

Browse files
committed
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
2 parents d7e74c9 + 7c81040 commit 35ca3e5

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

patch-ids.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44
#include "sha1-lookup.h"
55
#include "patch-ids.h"
66

7+
static int patch_id_defined(struct commit *commit)
8+
{
9+
/* must be 0 or 1 parents */
10+
return !commit->parents || !commit->parents->next;
11+
}
12+
713
int commit_patch_id(struct commit *commit, struct diff_options *options,
814
unsigned char *sha1, int diff_header_only)
915
{
16+
if (!patch_id_defined(commit))
17+
return -1;
18+
1019
if (commit->parents)
1120
diff_tree_sha1(commit->parents->item->object.oid.hash,
1221
commit->object.oid.hash, "", options);
@@ -45,6 +54,7 @@ int init_patch_ids(struct patch_ids *ids)
4554
{
4655
memset(ids, 0, sizeof(*ids));
4756
diff_setup(&ids->diffopts);
57+
ids->diffopts.detect_rename = 0;
4858
DIFF_OPT_SET(&ids->diffopts, RECURSIVE);
4959
diff_setup_done(&ids->diffopts);
5060
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,
7686
{
7787
struct patch_id patch;
7888

89+
if (!patch_id_defined(commit))
90+
return NULL;
91+
7992
memset(&patch, 0, sizeof(patch));
8093
if (init_patch_id_entry(&patch, commit, ids))
8194
return NULL;
@@ -88,6 +101,9 @@ struct patch_id *add_commit_patch_id(struct commit *commit,
88101
{
89102
struct patch_id *key = xcalloc(1, sizeof(*key));
90103

104+
if (!patch_id_defined(commit))
105+
return NULL;
106+
91107
if (init_patch_id_entry(key, commit, ids)) {
92108
free(key);
93109
return NULL;

0 commit comments

Comments
 (0)