| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 1 | #ifndef PATCH_IDS_H |
| 2 | #define PATCH_IDS_H |
| 3 | |
| Elijah Newren | ef3ca95 | 2018-08-15 17:54:05 | [diff] [blame] | 4 | #include "diff.h" |
| 5 | #include "hashmap.h" |
| 6 | |
| 7 | struct commit; |
| 8 | struct object_id; |
| Nguyễn Thái Ngọc Duy | a7edadd | 2018-09-21 15:57:30 | [diff] [blame] | 9 | struct repository; |
| Elijah Newren | ef3ca95 | 2018-08-15 17:54:05 | [diff] [blame] | 10 | |
| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 11 | struct patch_id { |
| Kevin Willford | dfb7a1b | 2016-07-29 16:19:17 | [diff] [blame] | 12 | struct hashmap_entry ent; |
| Brandon Williams | 34f3c0e | 2017-05-30 17:30:53 | [diff] [blame] | 13 | struct object_id patch_id; |
| Kevin Willford | 683f17e | 2016-07-29 16:19:18 | [diff] [blame] | 14 | struct commit *commit; |
| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 15 | }; |
| 16 | |
| 17 | struct patch_ids { |
| Kevin Willford | dfb7a1b | 2016-07-29 16:19:17 | [diff] [blame] | 18 | struct hashmap patches; |
| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 19 | struct diff_options diffopts; |
| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 20 | }; |
| 21 | |
| Xiaolong Ye | ded2c09 | 2016-04-26 07:51:21 | [diff] [blame] | 22 | int commit_patch_id(struct commit *commit, struct diff_options *options, |
| Stephen Boyd | a8f6855 | 2019-04-26 23:51:57 | [diff] [blame] | 23 | struct object_id *oid, int, int); |
| Nguyễn Thái Ngọc Duy | a7edadd | 2018-09-21 15:57:30 | [diff] [blame] | 24 | int init_patch_ids(struct repository *, struct patch_ids *); |
| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 25 | int free_patch_ids(struct patch_ids *); |
| Jeff King | c9e3a4e | 2021-01-12 15:52:32 | [diff] [blame] | 26 | |
| 27 | /* Add a patch_id for a single commit to the set. */ |
| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 28 | struct patch_id *add_commit_patch_id(struct commit *, struct patch_ids *); |
| Jeff King | c9e3a4e | 2021-01-12 15:52:32 | [diff] [blame] | 29 | |
| 30 | /* Returns true if the patch-id of "commit" is present in the set. */ |
| 31 | int has_commit_patch_id(struct commit *commit, struct patch_ids *); |
| 32 | |
| 33 | /* |
| 34 | * Iterate over all commits in the set whose patch id matches that of |
| 35 | * "commit", like: |
| 36 | * |
| 37 | * struct patch_id *cur; |
| 38 | * for (cur = patch_id_iter_first(commit, ids); |
| 39 | * cur; |
| 40 | * cur = patch_id_iter_next(cur, ids) { |
| 41 | * ... look at cur->commit |
| 42 | * } |
| 43 | */ |
| 44 | struct patch_id *patch_id_iter_first(struct commit *commit, struct patch_ids *); |
| 45 | struct patch_id *patch_id_iter_next(struct patch_id *cur, struct patch_ids *); |
| Junio C Hamano | 5d23e13 | 2007-04-10 00:01:27 | [diff] [blame] | 46 | |
| 47 | #endif /* PATCH_IDS_H */ |