blob: ab6c6a680474c9b2a37725fc9392683ac5a33083 [file] [log] [blame]
Junio C Hamano5d23e132007-04-09 17:01:27 -07001#ifndef PATCH_IDS_H
2#define PATCH_IDS_H
3
Elijah Newrenef3ca952018-08-15 10:54:05 -07004#include "diff.h"
5#include "hashmap.h"
6
7struct commit;
8struct object_id;
Nguyễn Thái Ngọc Duya7edadd2018-09-21 17:57:30 +02009struct repository;
Elijah Newrenef3ca952018-08-15 10:54:05 -070010
Junio C Hamano5d23e132007-04-09 17:01:27 -070011struct patch_id {
Kevin Willforddfb7a1b2016-07-29 12:19:17 -040012 struct hashmap_entry ent;
Brandon Williams34f3c0e2017-05-30 10:30:53 -070013 struct object_id patch_id;
Kevin Willford683f17e2016-07-29 12:19:18 -040014 struct commit *commit;
Junio C Hamano5d23e132007-04-09 17:01:27 -070015};
16
17struct patch_ids {
Kevin Willforddfb7a1b2016-07-29 12:19:17 -040018 struct hashmap patches;
Junio C Hamano5d23e132007-04-09 17:01:27 -070019 struct diff_options diffopts;
Junio C Hamano5d23e132007-04-09 17:01:27 -070020};
21
Xiaolong Yeded2c092016-04-26 15:51:21 +080022int commit_patch_id(struct commit *commit, struct diff_options *options,
Stephen Boyda8f68552019-04-26 16:51:57 -070023 struct object_id *oid, int, int);
Nguyễn Thái Ngọc Duya7edadd2018-09-21 17:57:30 +020024int init_patch_ids(struct repository *, struct patch_ids *);
Junio C Hamano5d23e132007-04-09 17:01:27 -070025int free_patch_ids(struct patch_ids *);
Jeff Kingc9e3a4e2021-01-12 10:52:32 -050026
27/* Add a patch_id for a single commit to the set. */
Junio C Hamano5d23e132007-04-09 17:01:27 -070028struct patch_id *add_commit_patch_id(struct commit *, struct patch_ids *);
Jeff Kingc9e3a4e2021-01-12 10:52:32 -050029
30/* Returns true if the patch-id of "commit" is present in the set. */
31int 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 */
44struct patch_id *patch_id_iter_first(struct commit *commit, struct patch_ids *);
45struct patch_id *patch_id_iter_next(struct patch_id *cur, struct patch_ids *);
Junio C Hamano5d23e132007-04-09 17:01:27 -070046
47#endif /* PATCH_IDS_H */