Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 1 | #ifndef COMMIT_H |
| 2 | #define COMMIT_H |
| 3 | |
| 4 | #include "object.h" |
| 5 | #include "tree.h" |
Pierre Habouzit | 674d172 | 2007-09-10 12:35:06 +0200 | [diff] [blame] | 6 | #include "strbuf.h" |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 7 | #include "decorate.h" |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 8 | #include "gpg-interface.h" |
Jeff King | a908047 | 2013-07-03 03:08:22 -0400 | [diff] [blame] | 9 | #include "string-list.h" |
Olga Telezhnaya | cf39471 | 2017-12-12 08:55:35 +0000 | [diff] [blame] | 10 | #include "pretty.h" |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 11 | |
| 12 | struct commit_list { |
| 13 | struct commit *item; |
| 14 | struct commit_list *next; |
| 15 | }; |
| 16 | |
| 17 | struct commit { |
| 18 | struct object object; |
Linus Torvalds | d3ff6f5 | 2006-06-17 18:26:18 -0700 | [diff] [blame] | 19 | void *util; |
Jeff King | 96c4f4a | 2013-04-09 02:52:56 -0400 | [diff] [blame] | 20 | unsigned int index; |
Johannes Schindelin | dddbad7 | 2017-04-26 21:29:31 +0200 | [diff] [blame] | 21 | timestamp_t date; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 22 | struct commit_list *parents; |
| 23 | struct tree *tree; |
| 24 | }; |
| 25 | |
Linus Torvalds | 60ab26d | 2005-09-15 14:43:17 -0700 | [diff] [blame] | 26 | extern int save_commit_buffer; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 27 | extern const char *commit_type; |
| 28 | |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 29 | /* While we can decorate any object with a name, it's only used for commits.. */ |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 30 | struct name_decoration { |
| 31 | struct name_decoration *next; |
Nazri Ramliy | eb3005e | 2010-06-19 09:37:33 +0800 | [diff] [blame] | 32 | int type; |
Jeff King | 2e3dfb2 | 2014-08-26 06:24:20 -0400 | [diff] [blame] | 33 | char name[FLEX_ARRAY]; |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
Jeff King | 662174d | 2014-08-26 06:23:36 -0400 | [diff] [blame] | 36 | enum decoration_type { |
| 37 | DECORATION_NONE = 0, |
| 38 | DECORATION_REF_LOCAL, |
| 39 | DECORATION_REF_REMOTE, |
| 40 | DECORATION_REF_TAG, |
| 41 | DECORATION_REF_STASH, |
| 42 | DECORATION_REF_HEAD, |
| 43 | DECORATION_GRAFTED, |
| 44 | }; |
| 45 | |
| 46 | void add_name_decoration(enum decoration_type type, const char *name, struct object *obj); |
Jeff King | 2608c24 | 2014-08-26 06:23:54 -0400 | [diff] [blame] | 47 | const struct name_decoration *get_name_decoration(const struct object *obj); |
Jeff King | 662174d | 2014-08-26 06:23:36 -0400 | [diff] [blame] | 48 | |
brian m. carlson | bc83266 | 2017-05-06 22:10:10 +0000 | [diff] [blame] | 49 | struct commit *lookup_commit(const struct object_id *oid); |
| 50 | struct commit *lookup_commit_reference(const struct object_id *oid); |
| 51 | struct commit *lookup_commit_reference_gently(const struct object_id *oid, |
Junio C Hamano | f76412e | 2005-08-21 02:51:10 -0700 | [diff] [blame] | 52 | int quiet); |
Pat Notz | a6fa599 | 2010-11-02 13:59:07 -0600 | [diff] [blame] | 53 | struct commit *lookup_commit_reference_by_name(const char *name); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 54 | |
Nguyễn Thái Ngọc Duy | baf18fc | 2011-09-17 21:57:45 +1000 | [diff] [blame] | 55 | /* |
brian m. carlson | bc83266 | 2017-05-06 22:10:10 +0000 | [diff] [blame] | 56 | * Look up object named by "oid", dereference tag as necessary, |
| 57 | * get a commit and return it. If "oid" does not dereference to |
Nguyễn Thái Ngọc Duy | baf18fc | 2011-09-17 21:57:45 +1000 | [diff] [blame] | 58 | * a commit, use ref_name to report an error and die. |
| 59 | */ |
brian m. carlson | bc83266 | 2017-05-06 22:10:10 +0000 | [diff] [blame] | 60 | struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name); |
Nguyễn Thái Ngọc Duy | baf18fc | 2011-09-17 21:57:45 +1000 | [diff] [blame] | 61 | |
Nguyễn Thái Ngọc Duy | cf7b1ca | 2011-02-05 17:52:20 +0700 | [diff] [blame] | 62 | int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size); |
Jeff King | 9cc2b07 | 2015-06-01 05:56:26 -0400 | [diff] [blame] | 63 | int parse_commit_gently(struct commit *item, int quiet_on_missing); |
| 64 | static inline int parse_commit(struct commit *item) |
| 65 | { |
| 66 | return parse_commit_gently(item, 0); |
| 67 | } |
Jeff King | 7059dcc | 2013-10-24 04:52:36 -0400 | [diff] [blame] | 68 | void parse_commit_or_die(struct commit *item); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 69 | |
Jeff King | 0fb370d | 2014-06-12 18:05:37 -0400 | [diff] [blame] | 70 | /* |
Jeff King | 66c2827 | 2014-06-10 17:40:14 -0400 | [diff] [blame] | 71 | * Associate an object buffer with the commit. The ownership of the |
| 72 | * memory is handed over to the commit, and must be free()-able. |
| 73 | */ |
Jeff King | 8597ea3 | 2014-06-10 17:44:13 -0400 | [diff] [blame] | 74 | void set_commit_buffer(struct commit *, void *buffer, unsigned long size); |
Jeff King | 66c2827 | 2014-06-10 17:40:14 -0400 | [diff] [blame] | 75 | |
| 76 | /* |
Jeff King | 152ff1c | 2014-06-10 17:40:39 -0400 | [diff] [blame] | 77 | * Get any cached object buffer associated with the commit. Returns NULL |
| 78 | * if none. The resulting memory should not be freed. |
| 79 | */ |
Jeff King | 8597ea3 | 2014-06-10 17:44:13 -0400 | [diff] [blame] | 80 | const void *get_cached_commit_buffer(const struct commit *, unsigned long *size); |
Jeff King | 152ff1c | 2014-06-10 17:40:39 -0400 | [diff] [blame] | 81 | |
| 82 | /* |
| 83 | * Get the commit's object contents, either from cache or by reading the object |
| 84 | * from disk. The resulting memory should not be modified, and must be given |
| 85 | * to unuse_commit_buffer when the caller is done. |
| 86 | */ |
Jeff King | 8597ea3 | 2014-06-10 17:44:13 -0400 | [diff] [blame] | 87 | const void *get_commit_buffer(const struct commit *, unsigned long *size); |
Jeff King | 152ff1c | 2014-06-10 17:40:39 -0400 | [diff] [blame] | 88 | |
| 89 | /* |
| 90 | * Tell the commit subsytem that we are done with a particular commit buffer. |
| 91 | * The commit and buffer should be the input and return value, respectively, |
| 92 | * from an earlier call to get_commit_buffer. The buffer may or may not be |
| 93 | * freed by this call; callers should not access the memory afterwards. |
| 94 | */ |
| 95 | void unuse_commit_buffer(const struct commit *, const void *buffer); |
| 96 | |
| 97 | /* |
Jeff King | 0fb370d | 2014-06-12 18:05:37 -0400 | [diff] [blame] | 98 | * Free any cached object buffer associated with the commit. |
| 99 | */ |
| 100 | void free_commit_buffer(struct commit *); |
| 101 | |
| 102 | /* |
| 103 | * Disassociate any cached object buffer from the commit, but do not free it. |
| 104 | * The buffer (or NULL, if none) is returned. |
| 105 | */ |
Jeff King | 8597ea3 | 2014-06-10 17:44:13 -0400 | [diff] [blame] | 106 | const void *detach_commit_buffer(struct commit *, unsigned long *sizep); |
Jeff King | 0fb370d | 2014-06-12 18:05:37 -0400 | [diff] [blame] | 107 | |
Christian Couder | 11af2aa | 2010-07-22 15:18:30 +0200 | [diff] [blame] | 108 | /* Find beginning and length of commit subject. */ |
| 109 | int find_commit_subject(const char *commit_buffer, const char **subject); |
| 110 | |
Thiago Farina | 47e44ed | 2010-11-26 23:58:14 -0200 | [diff] [blame] | 111 | struct commit_list *commit_list_insert(struct commit *item, |
| 112 | struct commit_list **list); |
René Scharfe | 89b5f1d | 2012-04-25 22:35:27 +0200 | [diff] [blame] | 113 | struct commit_list **commit_list_append(struct commit *commit, |
| 114 | struct commit_list **next); |
Miklos Vajna | 6531947 | 2008-06-27 18:21:55 +0200 | [diff] [blame] | 115 | unsigned commit_list_count(const struct commit_list *l); |
Thiago Farina | 47e44ed | 2010-11-26 23:58:14 -0200 | [diff] [blame] | 116 | struct commit_list *commit_list_insert_by_date(struct commit *item, |
| 117 | struct commit_list **list); |
| 118 | void commit_list_sort_by_date(struct commit_list **list); |
Daniel Barkalow | dd97f85 | 2005-04-23 18:47:23 -0700 | [diff] [blame] | 119 | |
Thomas Rast | 53d00b3 | 2013-07-31 22:13:20 +0200 | [diff] [blame] | 120 | /* Shallow copy of the input list */ |
| 121 | struct commit_list *copy_commit_list(struct commit_list *list); |
| 122 | |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 123 | void free_commit_list(struct commit_list *list); |
| 124 | |
René Scharfe | 6d167fd | 2017-03-01 12:37:07 +0100 | [diff] [blame] | 125 | struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ |
| 126 | |
Johannes Schindelin | 28e9cf6 | 2009-08-10 18:22:18 +0200 | [diff] [blame] | 127 | extern int has_non_ascii(const char *text); |
Jeff King | b000c59 | 2014-06-10 17:39:30 -0400 | [diff] [blame] | 128 | extern const char *logmsg_reencode(const struct commit *commit, |
| 129 | char **commit_encoding, |
| 130 | const char *output_encoding); |
Johannes Schindelin | 7735612 | 2016-06-22 22:20:16 +0200 | [diff] [blame] | 131 | extern const char *skip_blank_lines(const char *msg); |
Linus Torvalds | e3bc7a3 | 2005-06-01 08:34:23 -0700 | [diff] [blame] | 132 | |
Daniel Barkalow | dd97f85 | 2005-04-23 18:47:23 -0700 | [diff] [blame] | 133 | /** Removes the first commit from a list sorted by date, and adds all |
| 134 | * of its parents. |
| 135 | **/ |
Junio C Hamano | a6080a0 | 2007-06-07 00:04:01 -0700 | [diff] [blame] | 136 | struct commit *pop_most_recent_commit(struct commit_list **list, |
Daniel Barkalow | 58e28af | 2005-04-23 20:29:22 -0700 | [diff] [blame] | 137 | unsigned int mark); |
Daniel Barkalow | dd97f85 | 2005-04-23 18:47:23 -0700 | [diff] [blame] | 138 | |
jon@blackcubes.dyndns.org | a3437b8 | 2005-06-06 15:39:40 +0000 | [diff] [blame] | 139 | struct commit *pop_commit(struct commit_list **stack); |
| 140 | |
Junio C Hamano | f8f9c73 | 2006-01-07 18:52:42 -0800 | [diff] [blame] | 141 | void clear_commit_marks(struct commit *commit, unsigned int mark); |
Junio C Hamano | e895cb5 | 2013-03-05 11:42:20 -0800 | [diff] [blame] | 142 | void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark); |
Junio C Hamano | f8f9c73 | 2006-01-07 18:52:42 -0800 | [diff] [blame] | 143 | |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 144 | |
| 145 | enum rev_sort_order { |
| 146 | REV_SORT_IN_GRAPH_ORDER = 0, |
Junio C Hamano | 81c6b38 | 2013-06-07 10:35:54 -0700 | [diff] [blame] | 147 | REV_SORT_BY_COMMIT_DATE, |
| 148 | REV_SORT_BY_AUTHOR_DATE |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
Jon Seymour | ab580ac | 2005-07-07 02:39:34 +1000 | [diff] [blame] | 151 | /* |
| 152 | * Performs an in-place topological sort of list supplied. |
| 153 | * |
Jon Seymour | ab580ac | 2005-07-07 02:39:34 +1000 | [diff] [blame] | 154 | * invariant of resulting list is: |
| 155 | * a reachable from b => ord(b) < ord(a) |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 156 | * sort_order further specifies: |
| 157 | * REV_SORT_IN_GRAPH_ORDER: try to show a commit on a single-parent |
| 158 | * chain together. |
| 159 | * REV_SORT_BY_COMMIT_DATE: show eligible commits in committer-date order. |
Jon Seymour | ab580ac | 2005-07-07 02:39:34 +1000 | [diff] [blame] | 160 | */ |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 161 | void sort_in_topological_order(struct commit_list **, enum rev_sort_order); |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 162 | |
| 163 | struct commit_graft { |
brian m. carlson | 7683e2e | 2015-03-13 23:39:34 +0000 | [diff] [blame] | 164 | struct object_id oid; |
Johannes Schindelin | ed09aef | 2006-10-30 20:09:06 +0100 | [diff] [blame] | 165 | int nr_parent; /* < 0 if shallow commit */ |
brian m. carlson | 7683e2e | 2015-03-13 23:39:34 +0000 | [diff] [blame] | 166 | struct object_id parent[FLEX_ARRAY]; /* more */ |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 167 | }; |
Nguyễn Thái Ngọc Duy | 09d4664 | 2011-08-18 19:29:35 +0700 | [diff] [blame] | 168 | typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *); |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 169 | |
Patryk Obara | 9a93403 | 2017-08-18 20:33:12 +0200 | [diff] [blame] | 170 | struct commit_graft *read_graft_line(struct strbuf *line); |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 171 | int register_commit_graft(struct commit_graft *, int); |
Stefan Beller | 8b65a34 | 2017-07-12 17:44:14 -0700 | [diff] [blame] | 172 | struct commit_graft *lookup_commit_graft(const struct object_id *oid); |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 173 | |
Junio C Hamano | 2ce406c | 2014-10-30 12:20:44 -0700 | [diff] [blame] | 174 | extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2); |
| 175 | extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos); |
Miklos Vajna | 5240c9d | 2008-06-27 18:22:00 +0200 | [diff] [blame] | 176 | extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); |
Johannes Schindelin | 7c6f8aa | 2006-06-29 15:17:32 +0200 | [diff] [blame] | 177 | |
Junio C Hamano | 2ce406c | 2014-10-30 12:20:44 -0700 | [diff] [blame] | 178 | /* To be used only when object flags after this call no longer matter */ |
| 179 | extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos); |
| 180 | |
Stefano Lattarini | 41ccfdd | 2013-04-12 00:36:10 +0200 | [diff] [blame] | 181 | /* largest positive number a signed 32-bit integer can contain */ |
Nguyễn Thái Ngọc Duy | 4dcb167 | 2013-01-11 16:05:46 +0700 | [diff] [blame] | 182 | #define INFINITE_DEPTH 0x7fffffff |
| 183 | |
brian m. carlson | 910650d | 2017-03-31 01:40:00 +0000 | [diff] [blame] | 184 | struct oid_array; |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 185 | struct ref; |
brian m. carlson | e92b848 | 2017-05-06 22:10:06 +0000 | [diff] [blame] | 186 | extern int register_shallow(const struct object_id *oid); |
| 187 | extern int unregister_shallow(const struct object_id *oid); |
Nguyễn Thái Ngọc Duy | 09d4664 | 2011-08-18 19:29:35 +0700 | [diff] [blame] | 188 | extern int for_each_commit_graft(each_commit_graft_fn, void *); |
Junio C Hamano | f43117a | 2007-01-21 22:22:23 -0800 | [diff] [blame] | 189 | extern int is_repository_shallow(void); |
Johannes Schindelin | ed09aef | 2006-10-30 20:09:06 +0100 | [diff] [blame] | 190 | extern struct commit_list *get_shallow_commits(struct object_array *heads, |
Johannes Schindelin | f53514b | 2006-10-30 20:09:53 +0100 | [diff] [blame] | 191 | int depth, int shallow_flag, int not_shallow_flag); |
Nguyễn Thái Ngọc Duy | 3d9ff4d | 2016-06-12 17:53:57 +0700 | [diff] [blame] | 192 | extern struct commit_list *get_shallow_commits_by_rev_list( |
| 193 | int ac, const char **av, int shallow_flag, int not_shallow_flag); |
Nguyễn Thái Ngọc Duy | 069c053 | 2013-12-05 20:02:45 +0700 | [diff] [blame] | 194 | extern void set_alternate_shallow_file(const char *path, int override); |
Nguyễn Thái Ngọc Duy | 1a30f5a | 2013-12-05 20:02:34 +0700 | [diff] [blame] | 195 | extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol, |
brian m. carlson | 910650d | 2017-03-31 01:40:00 +0000 | [diff] [blame] | 196 | const struct oid_array *extra); |
Nguyễn Thái Ngọc Duy | 3125fe5 | 2013-08-16 16:52:02 +0700 | [diff] [blame] | 197 | extern void setup_alternate_shallow(struct lock_file *shallow_lock, |
Nguyễn Thái Ngọc Duy | 1a30f5a | 2013-12-05 20:02:34 +0700 | [diff] [blame] | 198 | const char **alternate_shallow_file, |
brian m. carlson | 910650d | 2017-03-31 01:40:00 +0000 | [diff] [blame] | 199 | const struct oid_array *extra); |
| 200 | extern const char *setup_temporary_shallow(const struct oid_array *extra); |
Nguyễn Thái Ngọc Duy | ad49136 | 2013-12-05 20:02:32 +0700 | [diff] [blame] | 201 | extern void advertise_shallow_grafts(int); |
Johannes Schindelin | ed09aef | 2006-10-30 20:09:06 +0100 | [diff] [blame] | 202 | |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 203 | struct shallow_info { |
brian m. carlson | 910650d | 2017-03-31 01:40:00 +0000 | [diff] [blame] | 204 | struct oid_array *shallow; |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 205 | int *ours, nr_ours; |
| 206 | int *theirs, nr_theirs; |
brian m. carlson | 910650d | 2017-03-31 01:40:00 +0000 | [diff] [blame] | 207 | struct oid_array *ref; |
Nguyễn Thái Ngọc Duy | 0a1bc12 | 2013-12-05 20:02:47 +0700 | [diff] [blame] | 208 | |
| 209 | /* for receive-pack */ |
| 210 | uint32_t **used_shallow; |
| 211 | int *need_reachability_test; |
| 212 | int *reachable; |
| 213 | int *shallow_ref; |
| 214 | struct commit **commits; |
| 215 | int nr_commits; |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 216 | }; |
| 217 | |
brian m. carlson | 910650d | 2017-03-31 01:40:00 +0000 | [diff] [blame] | 218 | extern void prepare_shallow_info(struct shallow_info *, struct oid_array *); |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 219 | extern void clear_shallow_info(struct shallow_info *); |
| 220 | extern void remove_nonexistent_theirs_shallow(struct shallow_info *); |
Nguyễn Thái Ngọc Duy | 8e27738 | 2013-12-05 20:02:36 +0700 | [diff] [blame] | 221 | extern void assign_shallow_commits_to_refs(struct shallow_info *info, |
| 222 | uint32_t **used, |
| 223 | int *ref_status); |
Nguyễn Thái Ngọc Duy | 0a1bc12 | 2013-12-05 20:02:47 +0700 | [diff] [blame] | 224 | extern int delayed_reachability_test(struct shallow_info *si, int c); |
Nguyễn Thái Ngọc Duy | eab3296 | 2013-12-05 20:02:54 +0700 | [diff] [blame] | 225 | extern void prune_shallow(int show_only); |
Karsten Blees | 6aa3085 | 2014-07-12 02:00:06 +0200 | [diff] [blame] | 226 | extern struct trace_key trace_shallow; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 227 | |
Jake Goulding | 7fcdb36 | 2009-01-26 09:13:24 -0500 | [diff] [blame] | 228 | int is_descendant_of(struct commit *, struct commit_list *); |
Junio C Hamano | a20efee | 2012-08-27 14:46:01 -0700 | [diff] [blame] | 229 | int in_merge_bases(struct commit *, struct commit *); |
Junio C Hamano | 4c4b27e | 2013-03-04 10:16:42 -0800 | [diff] [blame] | 230 | int in_merge_bases_many(struct commit *, int, struct commit **); |
Kristian Høgsberg | 5868016 | 2007-09-17 20:06:44 -0400 | [diff] [blame] | 231 | |
Conrad Irwin | b4bd466 | 2011-05-07 10:58:07 -0700 | [diff] [blame] | 232 | extern int interactive_add(int argc, const char **argv, const char *prefix, int patch); |
Thomas Rast | 46b5139 | 2009-08-13 14:29:41 +0200 | [diff] [blame] | 233 | extern int run_add_interactive(const char *revision, const char *patch_mode, |
Nguyễn Thái Ngọc Duy | 480ca64 | 2013-07-14 15:35:50 +0700 | [diff] [blame] | 234 | const struct pathspec *pathspec); |
Kristian Høgsberg | 5868016 | 2007-09-17 20:06:44 -0400 | [diff] [blame] | 235 | |
Martin Ågren | 4da7264 | 2017-11-07 21:39:45 +0100 | [diff] [blame] | 236 | /* |
| 237 | * Takes a list of commits and returns a new list where those |
| 238 | * have been removed that can be reached from other commits in |
| 239 | * the list. It is useful for, e.g., reducing the commits |
| 240 | * randomly thrown at the git-merge command and removing |
| 241 | * redundant commits that the user shouldn't have given to it. |
| 242 | * |
| 243 | * This function destroys the STALE bit of the commit objects' |
| 244 | * flags. |
| 245 | */ |
| 246 | extern struct commit_list *reduce_heads(struct commit_list *heads); |
| 247 | |
| 248 | /* |
| 249 | * Like `reduce_heads()`, except it replaces the list. Use this |
| 250 | * instead of `foo = reduce_heads(foo);` to avoid memory leaks. |
| 251 | */ |
| 252 | extern void reduce_heads_replace(struct commit_list **heads); |
Junio C Hamano | 98cf9c3 | 2008-06-27 18:22:03 +0200 | [diff] [blame] | 253 | |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 254 | struct commit_extra_header { |
| 255 | struct commit_extra_header *next; |
| 256 | char *key; |
| 257 | char *value; |
| 258 | size_t len; |
| 259 | }; |
| 260 | |
| 261 | extern void append_merge_tag_headers(struct commit_list *parents, |
| 262 | struct commit_extra_header ***tail); |
| 263 | |
Jeff King | 3ffefb5 | 2014-06-10 17:36:52 -0400 | [diff] [blame] | 264 | extern int commit_tree(const char *msg, size_t msg_len, |
Patryk Obara | 5078f34 | 2018-01-28 01:13:16 +0100 | [diff] [blame] | 265 | const struct object_id *tree, |
| 266 | struct commit_list *parents, struct object_id *ret, |
Junio C Hamano | ba3c69a | 2011-10-05 17:23:20 -0700 | [diff] [blame] | 267 | const char *author, const char *sign_commit); |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 268 | |
Jeff King | 3ffefb5 | 2014-06-10 17:36:52 -0400 | [diff] [blame] | 269 | extern int commit_tree_extended(const char *msg, size_t msg_len, |
Patryk Obara | 5078f34 | 2018-01-28 01:13:16 +0100 | [diff] [blame] | 270 | const struct object_id *tree, |
| 271 | struct commit_list *parents, |
| 272 | struct object_id *ret, const char *author, |
| 273 | const char *sign_commit, |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 274 | struct commit_extra_header *); |
| 275 | |
Junio C Hamano | c871a1d | 2012-01-05 10:54:14 -0800 | [diff] [blame] | 276 | extern struct commit_extra_header *read_commit_extra_headers(struct commit *, const char **); |
Junio C Hamano | ed7a42a | 2011-11-08 15:38:07 -0800 | [diff] [blame] | 277 | |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 278 | extern void free_commit_extra_headers(struct commit_extra_header *extra); |
Jeff King | 40d52ff | 2010-04-01 20:05:23 -0400 | [diff] [blame] | 279 | |
Jeff King | fe6eb7f | 2014-08-27 03:56:01 -0400 | [diff] [blame] | 280 | /* |
| 281 | * Search the commit object contents given by "msg" for the header "key". |
| 282 | * Returns a pointer to the start of the header contents, or NULL. The length |
| 283 | * of the header, up to the first newline, is returned via out_len. |
| 284 | * |
| 285 | * Note that some headers (like mergetag) may be multi-line. It is the caller's |
| 286 | * responsibility to parse further in this case! |
| 287 | */ |
| 288 | extern const char *find_commit_header(const char *msg, const char *key, |
| 289 | size_t *out_len); |
| 290 | |
Christian Couder | 8c38458 | 2014-11-09 10:23:41 +0100 | [diff] [blame] | 291 | /* Find the end of the log message, the right place for a new trailer. */ |
Jonathan Tan | 710714a | 2016-11-02 10:29:17 -0700 | [diff] [blame] | 292 | extern int ignore_non_trailer(const char *buf, size_t len); |
Christian Couder | 8c38458 | 2014-11-09 10:23:41 +0100 | [diff] [blame] | 293 | |
Christian Couder | 063da62 | 2014-07-07 08:35:37 +0200 | [diff] [blame] | 294 | typedef void (*each_mergetag_fn)(struct commit *commit, struct commit_extra_header *extra, |
| 295 | void *cb_data); |
| 296 | |
| 297 | extern void for_each_mergetag(each_mergetag_fn fn, struct commit *commit, void *data); |
| 298 | |
Junio C Hamano | ae8e4c9 | 2011-11-07 13:26:22 -0800 | [diff] [blame] | 299 | struct merge_remote_desc { |
| 300 | struct object *obj; /* the named object, could be a tag */ |
René Scharfe | 5447a76 | 2016-08-13 14:21:27 +0200 | [diff] [blame] | 301 | char name[FLEX_ARRAY]; |
Junio C Hamano | ae8e4c9 | 2011-11-07 13:26:22 -0800 | [diff] [blame] | 302 | }; |
| 303 | #define merge_remote_util(commit) ((struct merge_remote_desc *)((commit)->util)) |
René Scharfe | beb518c | 2016-08-13 14:11:27 +0200 | [diff] [blame] | 304 | extern void set_merge_remote_desc(struct commit *commit, |
| 305 | const char *name, struct object *obj); |
Junio C Hamano | ae8e4c9 | 2011-11-07 13:26:22 -0800 | [diff] [blame] | 306 | |
| 307 | /* |
| 308 | * Given "name" from the command line to merge, find the commit object |
| 309 | * and return it, while storing merge_remote_desc in its ->util field, |
| 310 | * to allow callers to tell if we are told to merge a tag. |
| 311 | */ |
| 312 | struct commit *get_merge_parent(const char *name); |
| 313 | |
Jeff King | 218aa3a | 2014-06-13 02:32:11 -0400 | [diff] [blame] | 314 | extern int parse_signed_commit(const struct commit *commit, |
Junio C Hamano | 0c37f1f | 2011-10-18 15:53:23 -0700 | [diff] [blame] | 315 | struct strbuf *message, struct strbuf *signature); |
Christian Couder | 0b05ab6 | 2014-07-19 17:01:12 +0200 | [diff] [blame] | 316 | extern int remove_signature(struct strbuf *buf); |
| 317 | |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 318 | /* |
Sebastian Götte | eb307ae | 2013-03-31 18:02:46 +0200 | [diff] [blame] | 319 | * Check the signature of the given commit. The result of the check is stored |
| 320 | * in sig->check_result, 'G' for a good signature, 'U' for a good signature |
| 321 | * from an untrusted signer, 'B' for a bad signature and 'N' for no signature |
| 322 | * at all. This may allocate memory for sig->gpg_output, sig->gpg_status, |
| 323 | * sig->signer and sig->key. |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 324 | */ |
brian m. carlson | 434060e | 2015-06-21 23:14:40 +0000 | [diff] [blame] | 325 | extern int check_commit_signature(const struct commit *commit, struct signature_check *sigc); |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 326 | |
Jeff King | 727377f | 2013-07-02 02:21:48 -0400 | [diff] [blame] | 327 | int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused); |
| 328 | |
Benoit Pierre | 15048f8 | 2014-03-18 11:00:53 +0100 | [diff] [blame] | 329 | LAST_ARG_MUST_BE_NULL |
| 330 | extern int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...); |
| 331 | |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 332 | #endif /* COMMIT_H */ |