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" |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 10 | |
| 11 | struct commit_list { |
| 12 | struct commit *item; |
| 13 | struct commit_list *next; |
| 14 | }; |
| 15 | |
| 16 | struct commit { |
| 17 | struct object object; |
Linus Torvalds | d3ff6f5 | 2006-06-17 18:26:18 -0700 | [diff] [blame] | 18 | void *util; |
Jeff King | 96c4f4a | 2013-04-09 02:52:56 -0400 | [diff] [blame] | 19 | unsigned int index; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 20 | unsigned long date; |
| 21 | struct commit_list *parents; |
| 22 | struct tree *tree; |
Linus Torvalds | bd1e17e | 2005-05-25 19:26:28 -0700 | [diff] [blame] | 23 | char *buffer; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 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.. */ |
| 30 | extern struct decoration name_decoration; |
| 31 | struct name_decoration { |
| 32 | struct name_decoration *next; |
Nazri Ramliy | eb3005e | 2010-06-19 09:37:33 +0800 | [diff] [blame] | 33 | int type; |
Linus Torvalds | ca135e7 | 2007-04-16 16:05:10 -0700 | [diff] [blame] | 34 | char name[1]; |
| 35 | }; |
| 36 | |
Jason McMullan | 5d6ccf5 | 2005-06-03 11:05:39 -0400 | [diff] [blame] | 37 | struct commit *lookup_commit(const unsigned char *sha1); |
| 38 | struct commit *lookup_commit_reference(const unsigned char *sha1); |
Junio C Hamano | f76412e | 2005-08-21 02:51:10 -0700 | [diff] [blame] | 39 | struct commit *lookup_commit_reference_gently(const unsigned char *sha1, |
| 40 | int quiet); |
Pat Notz | a6fa599 | 2010-11-02 13:59:07 -0600 | [diff] [blame] | 41 | struct commit *lookup_commit_reference_by_name(const char *name); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 42 | |
Nguyễn Thái Ngọc Duy | baf18fc | 2011-09-17 21:57:45 +1000 | [diff] [blame] | 43 | /* |
| 44 | * Look up object named by "sha1", dereference tag as necessary, |
| 45 | * get a commit and return it. If "sha1" does not dereference to |
| 46 | * a commit, use ref_name to report an error and die. |
| 47 | */ |
| 48 | struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name); |
| 49 | |
Nguyễn Thái Ngọc Duy | cf7b1ca | 2011-02-05 17:52:20 +0700 | [diff] [blame] | 50 | int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 51 | int parse_commit(struct commit *item); |
Jeff King | 7059dcc | 2013-10-24 04:52:36 -0400 | [diff] [blame] | 52 | void parse_commit_or_die(struct commit *item); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 53 | |
Christian Couder | 11af2aa | 2010-07-22 15:18:30 +0200 | [diff] [blame] | 54 | /* Find beginning and length of commit subject. */ |
| 55 | int find_commit_subject(const char *commit_buffer, const char **subject); |
| 56 | |
Thiago Farina | 47e44ed | 2010-11-26 23:58:14 -0200 | [diff] [blame] | 57 | struct commit_list *commit_list_insert(struct commit *item, |
| 58 | struct commit_list **list); |
René Scharfe | 89b5f1d | 2012-04-25 22:35:27 +0200 | [diff] [blame] | 59 | struct commit_list **commit_list_append(struct commit *commit, |
| 60 | struct commit_list **next); |
Miklos Vajna | 6531947 | 2008-06-27 18:21:55 +0200 | [diff] [blame] | 61 | unsigned commit_list_count(const struct commit_list *l); |
Thiago Farina | 47e44ed | 2010-11-26 23:58:14 -0200 | [diff] [blame] | 62 | struct commit_list *commit_list_insert_by_date(struct commit *item, |
| 63 | struct commit_list **list); |
| 64 | void commit_list_sort_by_date(struct commit_list **list); |
Daniel Barkalow | dd97f85 | 2005-04-23 18:47:23 -0700 | [diff] [blame] | 65 | |
Thomas Rast | 53d00b3 | 2013-07-31 22:13:20 +0200 | [diff] [blame] | 66 | /* Shallow copy of the input list */ |
| 67 | struct commit_list *copy_commit_list(struct commit_list *list); |
| 68 | |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 69 | void free_commit_list(struct commit_list *list); |
| 70 | |
Linus Torvalds | 000182e | 2005-06-05 09:02:03 -0700 | [diff] [blame] | 71 | /* Commit formats */ |
| 72 | enum cmit_fmt { |
| 73 | CMIT_FMT_RAW, |
| 74 | CMIT_FMT_MEDIUM, |
| 75 | CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, |
Linus Torvalds | 9b66ec0 | 2005-06-26 17:50:46 -0700 | [diff] [blame] | 76 | CMIT_FMT_SHORT, |
| 77 | CMIT_FMT_FULL, |
Junio C Hamano | ff56fe1 | 2005-11-09 22:15:27 -0800 | [diff] [blame] | 78 | CMIT_FMT_FULLER, |
Junio C Hamano | d87449c | 2005-08-08 22:15:40 -0700 | [diff] [blame] | 79 | CMIT_FMT_ONELINE, |
Junio C Hamano | 3eefc18 | 2006-04-18 16:45:27 -0700 | [diff] [blame] | 80 | CMIT_FMT_EMAIL, |
Johannes Schindelin | e52a5de | 2007-02-23 01:35:03 +0100 | [diff] [blame] | 81 | CMIT_FMT_USERFORMAT, |
Junio C Hamano | 6b9c58f | 2006-04-15 23:46:36 -0700 | [diff] [blame] | 82 | |
Gary V. Vaughan | 4b05548 | 2010-05-14 09:31:35 +0000 | [diff] [blame] | 83 | CMIT_FMT_UNSPECIFIED |
Linus Torvalds | 000182e | 2005-06-05 09:02:03 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Jonathan Nieder | 9cba13c | 2011-03-16 02:08:34 -0500 | [diff] [blame] | 86 | struct pretty_print_context { |
Jeff King | 10f2fbf | 2013-07-03 03:07:48 -0400 | [diff] [blame] | 87 | /* |
| 88 | * Callers should tweak these to change the behavior of pp_* functions. |
| 89 | */ |
Jeff King | 6bf1394 | 2011-05-26 18:27:49 -0400 | [diff] [blame] | 90 | enum cmit_fmt fmt; |
Thomas Rast | dd2e794 | 2009-10-19 17:48:08 +0200 | [diff] [blame] | 91 | int abbrev; |
| 92 | const char *subject; |
| 93 | const char *after_subject; |
Jeff King | 9553d2b | 2011-05-26 18:28:17 -0400 | [diff] [blame] | 94 | int preserve_subject; |
Thomas Rast | dd2e794 | 2009-10-19 17:48:08 +0200 | [diff] [blame] | 95 | enum date_mode date_mode; |
Jeff King | f026c75 | 2012-05-04 01:25:18 -0400 | [diff] [blame] | 96 | unsigned date_mode_explicit:1; |
Thomas Rast | dd2e794 | 2009-10-19 17:48:08 +0200 | [diff] [blame] | 97 | int need_8bit_cte; |
Junio C Hamano | ddf333f | 2012-10-17 18:51:47 -0700 | [diff] [blame] | 98 | char *notes_message; |
Thomas Rast | 8f8f547 | 2009-10-19 17:48:10 +0200 | [diff] [blame] | 99 | struct reflog_walk_info *reflog_info; |
Pat Notz | 177b29d | 2010-11-02 13:59:08 -0600 | [diff] [blame] | 100 | const char *output_encoding; |
Antoine Pelisse | 0e2913b | 2013-01-05 22:26:41 +0100 | [diff] [blame] | 101 | struct string_list *mailmap; |
Junio C Hamano | 3082517 | 2012-12-17 17:56:49 -0500 | [diff] [blame] | 102 | int color; |
Jeff King | a908047 | 2013-07-03 03:08:22 -0400 | [diff] [blame] | 103 | struct ident_split *from_ident; |
Jeff King | 10f2fbf | 2013-07-03 03:07:48 -0400 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * Fields below here are manipulated internally by pp_* functions and |
| 107 | * should not be counted on by callers. |
| 108 | */ |
Jeff King | a908047 | 2013-07-03 03:08:22 -0400 | [diff] [blame] | 109 | struct string_list in_body_headers; |
Thomas Rast | dd2e794 | 2009-10-19 17:48:08 +0200 | [diff] [blame] | 110 | }; |
| 111 | |
Johannes Gilger | 5b16360 | 2010-04-13 22:31:12 +0200 | [diff] [blame] | 112 | struct userformat_want { |
| 113 | unsigned notes:1; |
| 114 | }; |
| 115 | |
Johannes Schindelin | 28e9cf6 | 2009-08-10 18:22:18 +0200 | [diff] [blame] | 116 | extern int has_non_ascii(const char *text); |
Junio C Hamano | 4da45be | 2008-04-07 17:11:34 -0700 | [diff] [blame] | 117 | struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ |
Pat Notz | 177b29d | 2010-11-02 13:59:08 -0600 | [diff] [blame] | 118 | extern char *logmsg_reencode(const struct commit *commit, |
Nguyễn Thái Ngọc Duy | 5a10d23 | 2013-04-19 09:08:40 +1000 | [diff] [blame] | 119 | char **commit_encoding, |
Pat Notz | 177b29d | 2010-11-02 13:59:08 -0600 | [diff] [blame] | 120 | const char *output_encoding); |
Jeff King | dd0d388 | 2013-01-26 04:44:06 -0500 | [diff] [blame] | 121 | extern void logmsg_free(char *msg, const struct commit *commit); |
Junio C Hamano | 4da45be | 2008-04-07 17:11:34 -0700 | [diff] [blame] | 122 | extern void get_commit_format(const char *arg, struct rev_info *); |
Ramsay Jones | c8f1444 | 2011-04-07 19:26:23 +0100 | [diff] [blame] | 123 | extern const char *format_subject(struct strbuf *sb, const char *msg, |
| 124 | const char *line_separator); |
Johannes Gilger | 5b16360 | 2010-04-13 22:31:12 +0200 | [diff] [blame] | 125 | extern void userformat_find_requirements(const char *fmt, struct userformat_want *w); |
Pierre Habouzit | 674d172 | 2007-09-10 12:35:06 +0200 | [diff] [blame] | 126 | extern void format_commit_message(const struct commit *commit, |
Junio C Hamano | 7f98ebc | 2009-10-15 22:59:41 -0700 | [diff] [blame] | 127 | const char *format, struct strbuf *sb, |
Thomas Rast | dd2e794 | 2009-10-19 17:48:08 +0200 | [diff] [blame] | 128 | const struct pretty_print_context *context); |
Jeff King | 10f2fbf | 2013-07-03 03:07:48 -0400 | [diff] [blame] | 129 | extern void pretty_print_commit(struct pretty_print_context *pp, |
Jeff King | 6bf1394 | 2011-05-26 18:27:49 -0400 | [diff] [blame] | 130 | const struct commit *commit, |
| 131 | struct strbuf *sb); |
Jeff King | 8b8a537 | 2011-05-26 18:27:24 -0400 | [diff] [blame] | 132 | extern void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit, |
| 133 | struct strbuf *sb); |
Jeff King | 10f2fbf | 2013-07-03 03:07:48 -0400 | [diff] [blame] | 134 | void pp_user_info(struct pretty_print_context *pp, |
Jeff King | 6bf1394 | 2011-05-26 18:27:49 -0400 | [diff] [blame] | 135 | const char *what, struct strbuf *sb, |
| 136 | const char *line, const char *encoding); |
Jeff King | 10f2fbf | 2013-07-03 03:07:48 -0400 | [diff] [blame] | 137 | void pp_title_line(struct pretty_print_context *pp, |
Daniel Barkalow | b02bd65 | 2008-02-18 22:56:08 -0500 | [diff] [blame] | 138 | const char **msg_p, |
| 139 | struct strbuf *sb, |
Daniel Barkalow | b02bd65 | 2008-02-18 22:56:08 -0500 | [diff] [blame] | 140 | const char *encoding, |
Junio C Hamano | 267123b | 2008-03-15 00:09:20 -0700 | [diff] [blame] | 141 | int need_8bit_cte); |
Jeff King | 10f2fbf | 2013-07-03 03:07:48 -0400 | [diff] [blame] | 142 | void pp_remainder(struct pretty_print_context *pp, |
Daniel Barkalow | b02bd65 | 2008-02-18 22:56:08 -0500 | [diff] [blame] | 143 | const char **msg_p, |
| 144 | struct strbuf *sb, |
| 145 | int indent); |
| 146 | |
Linus Torvalds | e3bc7a3 | 2005-06-01 08:34:23 -0700 | [diff] [blame] | 147 | |
Daniel Barkalow | dd97f85 | 2005-04-23 18:47:23 -0700 | [diff] [blame] | 148 | /** Removes the first commit from a list sorted by date, and adds all |
| 149 | * of its parents. |
| 150 | **/ |
Junio C Hamano | a6080a0 | 2007-06-07 00:04:01 -0700 | [diff] [blame] | 151 | struct commit *pop_most_recent_commit(struct commit_list **list, |
Daniel Barkalow | 58e28af | 2005-04-23 20:29:22 -0700 | [diff] [blame] | 152 | unsigned int mark); |
Daniel Barkalow | dd97f85 | 2005-04-23 18:47:23 -0700 | [diff] [blame] | 153 | |
jon@blackcubes.dyndns.org | a3437b8 | 2005-06-06 15:39:40 +0000 | [diff] [blame] | 154 | struct commit *pop_commit(struct commit_list **stack); |
| 155 | |
Junio C Hamano | f8f9c73 | 2006-01-07 18:52:42 -0800 | [diff] [blame] | 156 | void clear_commit_marks(struct commit *commit, unsigned int mark); |
Junio C Hamano | e895cb5 | 2013-03-05 11:42:20 -0800 | [diff] [blame] | 157 | void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark); |
René Scharfe | 86a0a40 | 2011-10-01 18:16:08 +0200 | [diff] [blame] | 158 | void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark); |
Junio C Hamano | f8f9c73 | 2006-01-07 18:52:42 -0800 | [diff] [blame] | 159 | |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 160 | |
| 161 | enum rev_sort_order { |
| 162 | REV_SORT_IN_GRAPH_ORDER = 0, |
Junio C Hamano | 81c6b38 | 2013-06-07 10:35:54 -0700 | [diff] [blame] | 163 | REV_SORT_BY_COMMIT_DATE, |
| 164 | REV_SORT_BY_AUTHOR_DATE |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 165 | }; |
| 166 | |
Jon Seymour | ab580ac | 2005-07-07 02:39:34 +1000 | [diff] [blame] | 167 | /* |
| 168 | * Performs an in-place topological sort of list supplied. |
| 169 | * |
Jon Seymour | ab580ac | 2005-07-07 02:39:34 +1000 | [diff] [blame] | 170 | * invariant of resulting list is: |
| 171 | * a reachable from b => ord(b) < ord(a) |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 172 | * sort_order further specifies: |
| 173 | * REV_SORT_IN_GRAPH_ORDER: try to show a commit on a single-parent |
| 174 | * chain together. |
| 175 | * REV_SORT_BY_COMMIT_DATE: show eligible commits in committer-date order. |
Jon Seymour | ab580ac | 2005-07-07 02:39:34 +1000 | [diff] [blame] | 176 | */ |
Junio C Hamano | 08f704f | 2013-06-06 16:07:14 -0700 | [diff] [blame] | 177 | 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] | 178 | |
| 179 | struct commit_graft { |
| 180 | unsigned char sha1[20]; |
Johannes Schindelin | ed09aef | 2006-10-30 20:09:06 +0100 | [diff] [blame] | 181 | int nr_parent; /* < 0 if shallow commit */ |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 182 | unsigned char parent[FLEX_ARRAY][20]; /* more */ |
| 183 | }; |
Nguyễn Thái Ngọc Duy | 09d4664 | 2011-08-18 19:29:35 +0700 | [diff] [blame] | 184 | typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *); |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 185 | |
| 186 | struct commit_graft *read_graft_line(char *buf, int len); |
| 187 | int register_commit_graft(struct commit_graft *, int); |
Martin Koegler | 4516338 | 2008-02-25 22:46:07 +0100 | [diff] [blame] | 188 | struct commit_graft *lookup_commit_graft(const unsigned char *sha1); |
Junio C Hamano | 5040f17 | 2006-04-06 23:58:51 -0700 | [diff] [blame] | 189 | |
Rene Scharfe | c0fa825 | 2006-07-02 11:49:38 +0200 | [diff] [blame] | 190 | extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup); |
Christian Couder | 53eda89 | 2008-07-30 07:04:14 +0200 | [diff] [blame] | 191 | extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos, int cleanup); |
Miklos Vajna | 5240c9d | 2008-06-27 18:22:00 +0200 | [diff] [blame] | 192 | extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); |
Johannes Schindelin | 7c6f8aa | 2006-06-29 15:17:32 +0200 | [diff] [blame] | 193 | |
Stefano Lattarini | 41ccfdd | 2013-04-12 00:36:10 +0200 | [diff] [blame] | 194 | /* 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] | 195 | #define INFINITE_DEPTH 0x7fffffff |
| 196 | |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 197 | struct sha1_array; |
| 198 | struct ref; |
Johannes Schindelin | ed09aef | 2006-10-30 20:09:06 +0100 | [diff] [blame] | 199 | extern int register_shallow(const unsigned char *sha1); |
Johannes Schindelin | f53514b | 2006-10-30 20:09:53 +0100 | [diff] [blame] | 200 | extern int unregister_shallow(const unsigned char *sha1); |
Nguyễn Thái Ngọc Duy | 09d4664 | 2011-08-18 19:29:35 +0700 | [diff] [blame] | 201 | extern int for_each_commit_graft(each_commit_graft_fn, void *); |
Junio C Hamano | f43117a | 2007-01-21 22:22:23 -0800 | [diff] [blame] | 202 | extern int is_repository_shallow(void); |
Johannes Schindelin | ed09aef | 2006-10-30 20:09:06 +0100 | [diff] [blame] | 203 | extern struct commit_list *get_shallow_commits(struct object_array *heads, |
Johannes Schindelin | f53514b | 2006-10-30 20:09:53 +0100 | [diff] [blame] | 204 | int depth, int shallow_flag, int not_shallow_flag); |
Nguyễn Thái Ngọc Duy | 6035d6a | 2013-05-26 08:16:15 +0700 | [diff] [blame] | 205 | extern void check_shallow_file_for_update(void); |
Nguyễn Thái Ngọc Duy | 069c053 | 2013-12-05 20:02:45 +0700 | [diff] [blame] | 206 | 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] | 207 | extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol, |
| 208 | const struct sha1_array *extra); |
Nguyễn Thái Ngọc Duy | 3125fe5 | 2013-08-16 16:52:02 +0700 | [diff] [blame] | 209 | 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] | 210 | const char **alternate_shallow_file, |
| 211 | const struct sha1_array *extra); |
| 212 | extern char *setup_temporary_shallow(const struct sha1_array *extra); |
Nguyễn Thái Ngọc Duy | ad49136 | 2013-12-05 20:02:32 +0700 | [diff] [blame] | 213 | extern void advertise_shallow_grafts(int); |
Johannes Schindelin | ed09aef | 2006-10-30 20:09:06 +0100 | [diff] [blame] | 214 | |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 215 | struct shallow_info { |
| 216 | struct sha1_array *shallow; |
| 217 | int *ours, nr_ours; |
| 218 | int *theirs, nr_theirs; |
| 219 | struct sha1_array *ref; |
Nguyễn Thái Ngọc Duy | 0a1bc12 | 2013-12-05 20:02:47 +0700 | [diff] [blame] | 220 | |
| 221 | /* for receive-pack */ |
| 222 | uint32_t **used_shallow; |
| 223 | int *need_reachability_test; |
| 224 | int *reachable; |
| 225 | int *shallow_ref; |
| 226 | struct commit **commits; |
| 227 | int nr_commits; |
Nguyễn Thái Ngọc Duy | 58babff | 2013-12-05 20:02:35 +0700 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | extern void prepare_shallow_info(struct shallow_info *, struct sha1_array *); |
| 231 | extern void clear_shallow_info(struct shallow_info *); |
| 232 | 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] | 233 | extern void assign_shallow_commits_to_refs(struct shallow_info *info, |
| 234 | uint32_t **used, |
| 235 | int *ref_status); |
Nguyễn Thái Ngọc Duy | 0a1bc12 | 2013-12-05 20:02:47 +0700 | [diff] [blame] | 236 | 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] | 237 | extern void prune_shallow(int show_only); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 238 | |
Jake Goulding | 7fcdb36 | 2009-01-26 09:13:24 -0500 | [diff] [blame] | 239 | int is_descendant_of(struct commit *, struct commit_list *); |
Junio C Hamano | a20efee | 2012-08-27 14:46:01 -0700 | [diff] [blame] | 240 | int in_merge_bases(struct commit *, struct commit *); |
Junio C Hamano | 4c4b27e | 2013-03-04 10:16:42 -0800 | [diff] [blame] | 241 | int in_merge_bases_many(struct commit *, int, struct commit **); |
Kristian Høgsberg | 5868016 | 2007-09-17 20:06:44 -0400 | [diff] [blame] | 242 | |
Conrad Irwin | b4bd466 | 2011-05-07 10:58:07 -0700 | [diff] [blame] | 243 | 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] | 244 | 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] | 245 | const struct pathspec *pathspec); |
Kristian Høgsberg | 5868016 | 2007-09-17 20:06:44 -0400 | [diff] [blame] | 246 | |
Linus Torvalds | 53b2c82 | 2007-11-05 13:22:34 -0800 | [diff] [blame] | 247 | static inline int single_parent(struct commit *commit) |
| 248 | { |
| 249 | return commit->parents && !commit->parents->next; |
| 250 | } |
| 251 | |
Junio C Hamano | 98cf9c3 | 2008-06-27 18:22:03 +0200 | [diff] [blame] | 252 | struct commit_list *reduce_heads(struct commit_list *heads); |
| 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 | |
Nguyễn Thái Ngọc Duy | 8785b76 | 2013-12-22 09:56:41 +0700 | [diff] [blame] | 264 | extern int commit_tree(const struct strbuf *msg, const unsigned char *tree, |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 265 | struct commit_list *parents, unsigned char *ret, |
Junio C Hamano | ba3c69a | 2011-10-05 17:23:20 -0700 | [diff] [blame] | 266 | const char *author, const char *sign_commit); |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 267 | |
Nguyễn Thái Ngọc Duy | 8785b76 | 2013-12-22 09:56:41 +0700 | [diff] [blame] | 268 | extern int commit_tree_extended(const struct strbuf *msg, const unsigned char *tree, |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 269 | struct commit_list *parents, unsigned char *ret, |
Junio C Hamano | ba3c69a | 2011-10-05 17:23:20 -0700 | [diff] [blame] | 270 | const char *author, const char *sign_commit, |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 271 | struct commit_extra_header *); |
| 272 | |
Junio C Hamano | c871a1d | 2012-01-05 10:54:14 -0800 | [diff] [blame] | 273 | 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] | 274 | |
Junio C Hamano | 5231c63 | 2011-11-07 16:21:32 -0800 | [diff] [blame] | 275 | extern void free_commit_extra_headers(struct commit_extra_header *extra); |
Jeff King | 40d52ff | 2010-04-01 20:05:23 -0400 | [diff] [blame] | 276 | |
Junio C Hamano | ae8e4c9 | 2011-11-07 13:26:22 -0800 | [diff] [blame] | 277 | struct merge_remote_desc { |
| 278 | struct object *obj; /* the named object, could be a tag */ |
| 279 | const char *name; |
| 280 | }; |
| 281 | #define merge_remote_util(commit) ((struct merge_remote_desc *)((commit)->util)) |
| 282 | |
| 283 | /* |
| 284 | * Given "name" from the command line to merge, find the commit object |
| 285 | * and return it, while storing merge_remote_desc in its ->util field, |
| 286 | * to allow callers to tell if we are told to merge a tag. |
| 287 | */ |
| 288 | struct commit *get_merge_parent(const char *name); |
| 289 | |
Junio C Hamano | 0c37f1f | 2011-10-18 15:53:23 -0700 | [diff] [blame] | 290 | extern int parse_signed_commit(const unsigned char *sha1, |
| 291 | struct strbuf *message, struct strbuf *signature); |
Nguyễn Thái Ngọc Duy | efc7df4 | 2012-10-26 22:53:51 +0700 | [diff] [blame] | 292 | extern void print_commit_list(struct commit_list *list, |
| 293 | const char *format_cur, |
| 294 | const char *format_last); |
| 295 | |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 296 | /* |
Sebastian Götte | eb307ae | 2013-03-31 18:02:46 +0200 | [diff] [blame] | 297 | * Check the signature of the given commit. The result of the check is stored |
| 298 | * in sig->check_result, 'G' for a good signature, 'U' for a good signature |
| 299 | * from an untrusted signer, 'B' for a bad signature and 'N' for no signature |
| 300 | * at all. This may allocate memory for sig->gpg_output, sig->gpg_status, |
| 301 | * sig->signer and sig->key. |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 302 | */ |
| 303 | extern void check_commit_signature(const struct commit* commit, struct signature_check *sigc); |
| 304 | |
Jeff King | 727377f | 2013-07-02 02:21:48 -0400 | [diff] [blame] | 305 | int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused); |
| 306 | |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 307 | #endif /* COMMIT_H */ |