Expand file tree
/
Copy pathcommit.h
More file actions
Latest commit
233 lines (193 loc) · 7.56 KB
/
Copy pathcommit.h
File metadata and controls
233 lines (193 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#ifndefCOMMIT_H
#defineCOMMIT_H
#include"object.h"
#include"tree.h"
#include"strbuf.h"
#include"decorate.h"
structcommit_list {
structcommit*item;
structcommit_list*next;
};
structcommit {
structobjectobject;
void*util;
unsigned intindegree;
unsigned longdate;
structcommit_list*parents;
structtree*tree;
char*buffer;
};
externintsave_commit_buffer;
externconstchar*commit_type;
/* While we can decorate any object with a name, it's only used for commits.. */
externstructdecorationname_decoration;
structname_decoration {
structname_decoration*next;
inttype;
charname[1];
};
structcommit*lookup_commit(constunsigned char*sha1);
structcommit*lookup_commit_reference(constunsigned char*sha1);
structcommit*lookup_commit_reference_gently(constunsigned char*sha1,
intquiet);
structcommit*lookup_commit_reference_by_name(constchar*name);
/*
* Look up object named by "sha1", dereference tag as necessary,
* get a commit and return it. If "sha1" does not dereference to
* a commit, use ref_name to report an error and die.
*/
structcommit*lookup_commit_or_die(constunsigned char*sha1, constchar*ref_name);
intparse_commit_buffer(structcommit*item, constvoid*buffer, unsigned longsize);
intparse_commit(structcommit*item);
/* Find beginning and length of commit subject. */
intfind_commit_subject(constchar*commit_buffer, constchar**subject);
structcommit_list*commit_list_insert(structcommit*item,
structcommit_list**list);
structcommit_list**commit_list_append(structcommit*commit,
structcommit_list**next);
unsignedcommit_list_count(conststructcommit_list*l);
structcommit_list*commit_list_insert_by_date(structcommit*item,
structcommit_list**list);
voidcommit_list_sort_by_date(structcommit_list**list);
voidfree_commit_list(structcommit_list*list);
/* Commit formats */
enumcmit_fmt {
CMIT_FMT_RAW,
CMIT_FMT_MEDIUM,
CMIT_FMT_DEFAULT=CMIT_FMT_MEDIUM,
CMIT_FMT_SHORT,
CMIT_FMT_FULL,
CMIT_FMT_FULLER,
CMIT_FMT_ONELINE,
CMIT_FMT_EMAIL,
CMIT_FMT_USERFORMAT,
CMIT_FMT_UNSPECIFIED
};
structpretty_print_context {
enumcmit_fmtfmt;
intabbrev;
constchar*subject;
constchar*after_subject;
intpreserve_subject;
enumdate_modedate_mode;
unsigneddate_mode_explicit:1;
intneed_8bit_cte;
char*notes_message;
structreflog_walk_info*reflog_info;
constchar*output_encoding;
structstring_list*mailmap;
intcolor;
};
structuserformat_want {
unsignednotes:1;
};
externinthas_non_ascii(constchar*text);
structrev_info; /* in revision.h, it circularly uses enum cmit_fmt */
externchar*logmsg_reencode(conststructcommit*commit,
constchar*output_encoding);
externvoidlogmsg_free(char*msg, conststructcommit*commit);
externvoidget_commit_format(constchar*arg, structrev_info*);
externconstchar*format_subject(structstrbuf*sb, constchar*msg,
constchar*line_separator);
externvoiduserformat_find_requirements(constchar*fmt, structuserformat_want*w);
externvoidformat_commit_message(conststructcommit*commit,
constchar*format, structstrbuf*sb,
conststructpretty_print_context*context);
externvoidpretty_print_commit(conststructpretty_print_context*pp,
conststructcommit*commit,
structstrbuf*sb);
externvoidpp_commit_easy(enumcmit_fmtfmt, conststructcommit*commit,
structstrbuf*sb);
voidpp_user_info(conststructpretty_print_context*pp,
constchar*what, structstrbuf*sb,
constchar*line, constchar*encoding);
voidpp_title_line(conststructpretty_print_context*pp,
constchar**msg_p,
structstrbuf*sb,
constchar*encoding,
intneed_8bit_cte);
voidpp_remainder(conststructpretty_print_context*pp,
constchar**msg_p,
structstrbuf*sb,
intindent);
/** Removes the first commit from a list sorted by date, and adds all
* of its parents.
**/
structcommit*pop_most_recent_commit(structcommit_list**list,
unsigned intmark);
structcommit*pop_commit(structcommit_list**stack);
voidclear_commit_marks(structcommit*commit, unsigned intmark);
voidclear_commit_marks_for_object_array(structobject_array*a, unsignedmark);
/*
* Performs an in-place topological sort of list supplied.
*
* invariant of resulting list is:
* a reachable from b => ord(b) < ord(a)
* in addition, when lifo == 0, commits on parallel tracks are
* sorted in the dates order.
*/
voidsort_in_topological_order(structcommit_list**list, intlifo);
structcommit_graft {
unsigned charsha1[20];
intnr_parent; /* < 0 if shallow commit */
unsigned charparent[FLEX_ARRAY][20]; /* more */
};
typedefint (*each_commit_graft_fn)(conststructcommit_graft*, void*);
structcommit_graft*read_graft_line(char*buf, intlen);
intregister_commit_graft(structcommit_graft*, int);
structcommit_graft*lookup_commit_graft(constunsigned char*sha1);
externstructcommit_list*get_merge_bases(structcommit*rev1, structcommit*rev2, intcleanup);
externstructcommit_list*get_merge_bases_many(structcommit*one, intn, structcommit**twos, intcleanup);
externstructcommit_list*get_octopus_merge_bases(structcommit_list*in);
/* largest postive number a signed 32-bit integer can contain */
#defineINFINITE_DEPTH 0x7fffffff
externintregister_shallow(constunsigned char*sha1);
externintunregister_shallow(constunsigned char*sha1);
externintfor_each_commit_graft(each_commit_graft_fn, void*);
externintis_repository_shallow(void);
externstructcommit_list*get_shallow_commits(structobject_array*heads,
intdepth, intshallow_flag, intnot_shallow_flag);
intis_descendant_of(structcommit*, structcommit_list*);
intin_merge_bases(structcommit*, structcommit*);
externintinteractive_add(intargc, constchar**argv, constchar*prefix, intpatch);
externintrun_add_interactive(constchar*revision, constchar*patch_mode,
constchar**pathspec);
staticinlineintsingle_parent(structcommit*commit)
{
returncommit->parents&& !commit->parents->next;
}
structcommit_list*reduce_heads(structcommit_list*heads);
structcommit_extra_header {
structcommit_extra_header*next;
char*key;
char*value;
size_tlen;
};
externvoidappend_merge_tag_headers(structcommit_list*parents,
structcommit_extra_header***tail);
externintcommit_tree(conststructstrbuf*msg, unsigned char*tree,
structcommit_list*parents, unsigned char*ret,
constchar*author, constchar*sign_commit);
externintcommit_tree_extended(conststructstrbuf*msg, unsigned char*tree,
structcommit_list*parents, unsigned char*ret,
constchar*author, constchar*sign_commit,
structcommit_extra_header*);
externstructcommit_extra_header*read_commit_extra_headers(structcommit*, constchar**);
externvoidfree_commit_extra_headers(structcommit_extra_header*extra);
structmerge_remote_desc {
structobject*obj; /* the named object, could be a tag */
constchar*name;
};
#definemerge_remote_util(commit) ((struct merge_remote_desc *)((commit)->util))
/*
* Given "name" from the command line to merge, find the commit object
* and return it, while storing merge_remote_desc in its ->util field,
* to allow callers to tell if we are told to merge a tag.
*/
structcommit*get_merge_parent(constchar*name);
externintparse_signed_commit(constunsigned char*sha1,
structstrbuf*message, structstrbuf*signature);
externvoidprint_commit_list(structcommit_list*list,
constchar*format_cur,
constchar*format_last);
#endif/* COMMIT_H */