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 <kcwillford@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kevin Willford committed
Jul 29, 2016 at 12:19 UTC
683f17ec440afafd2b375fd1b7a80a1aca219b4f
3 files changed
+5
-16
patch-ids.c
+1
@@ -43,6 +43,7 @@ static int init_patch_id_entry(struct patch_id *patch,
43
struct commit *commit,
44
struct patch_ids *ids)
45
{
46
+ patch->commit = commit;
47
if (commit_patch_id(commit, &ids->diffopts, patch->patch_id))
48
return -1;
49
patch-ids.h
+1
-1
@@ -4,7 +4,7 @@
4
struct patch_id {
5
struct hashmap_entry ent;
6
unsigned char patch_id[GIT_SHA1_RAWSZ];
7
- char seen;
7
+ struct commit *commit;
8
};
9
10
struct patch_ids {
revision.c
+3
-15
@@ -846,7 +846,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
846
*/
847
if (left_first != !!(flags & SYMMETRIC_LEFT))
848
continue;
849
- commit->util = add_commit_patch_id(commit, &ids);
849
+ add_commit_patch_id(commit, &ids);
850
}
851
852
/* 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)
873
id = has_commit_patch_id(commit, &ids);
874
if (!id)
875
continue;
876
- id->seen = 1;
877
- commit->object.flags |= cherry_flag;
878
- }
876
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;
879
}
880
881
free_patch_ids(&ids);