Skip to content

Commit 683f17e

Browse files
Kevin Willfordgitster
authored andcommitted
patch-ids: replace the seen indicator with a commit pointer
The cherry_pick_list was looping through the original side checking the seen indicator and setting the cherry_flag on the commit. If we save off the commit in the patch_id we can set the cherry_flag on the correct commit when running through the other side when a patch_id match is found. Signed-off-by: Kevin Willford <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dfb7a1b commit 683f17e

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

patch-ids.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static int init_patch_id_entry(struct patch_id *patch,
4343
struct commit *commit,
4444
struct patch_ids *ids)
4545
{
46+
patch->commit = commit;
4647
if (commit_patch_id(commit, &ids->diffopts, patch->patch_id))
4748
return -1;
4849

patch-ids.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
struct patch_id {
55
struct hashmap_entry ent;
66
unsigned char patch_id[GIT_SHA1_RAWSZ];
7-
char seen;
7+
struct commit *commit;
88
};
99

1010
struct patch_ids {

revision.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
846846
*/
847847
if (left_first != !!(flags & SYMMETRIC_LEFT))
848848
continue;
849-
commit->util = add_commit_patch_id(commit, &ids);
849+
add_commit_patch_id(commit, &ids);
850850
}
851851

852852
/* either cherry_mark or cherry_pick are true */
@@ -873,21 +873,9 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
873873
id = has_commit_patch_id(commit, &ids);
874874
if (!id)
875875
continue;
876-
id->seen = 1;
877-
commit->object.flags |= cherry_flag;
878-
}
879876

880-
/* Now check the original side for seen ones */
881-
for (p = list; p; p = p->next) {
882-
struct commit *commit = p->item;
883-
struct patch_id *ent;
884-
885-
ent = commit->util;
886-
if (!ent)
887-
continue;
888-
if (ent->seen)
889-
commit->object.flags |= cherry_flag;
890-
commit->util = NULL;
877+
commit->object.flags |= cherry_flag;
878+
id->commit->object.flags |= cherry_flag;
891879
}
892880

893881
free_patch_ids(&ids);

0 commit comments

Comments
 (0)