Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
forked from git-for-windows/git
- Notifications
You must be signed in to change notification settings - Fork 310
Expand file tree
/
Copy pathcommit.h
More file actions
Latest commit
356 lines (297 loc) · 11.9 KB
/
Copy pathcommit.h
File metadata and controls
356 lines (297 loc) · 11.9 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#ifndefCOMMIT_H
#defineCOMMIT_H
#include"object.h"
#include"tree.h"
#include"strbuf.h"
#include"decorate.h"
#include"gpg-interface.h"
#include"string-list.h"
structcommit_list {
structcommit*item;
structcommit_list*next;
};
structcommit {
structobjectobject;
void*util;
unsigned intindex;
unsigned longdate;
structcommit_list*parents;
structtree*tree;
};
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);
voidparse_commit_or_die(structcommit*item);
/*
* Associate an object buffer with the commit. The ownership of the
* memory is handed over to the commit, and must be free()-able.
*/
voidset_commit_buffer(structcommit*, void*buffer, unsigned longsize);
/*
* Get any cached object buffer associated with the commit. Returns NULL
* if none. The resulting memory should not be freed.
*/
constvoid*get_cached_commit_buffer(conststructcommit*, unsigned long*size);
/*
* Get the commit's object contents, either from cache or by reading the object
* from disk. The resulting memory should not be modified, and must be given
* to unuse_commit_buffer when the caller is done.
*/
constvoid*get_commit_buffer(conststructcommit*, unsigned long*size);
/*
* Tell the commit subsytem that we are done with a particular commit buffer.
* The commit and buffer should be the input and return value, respectively,
* from an earlier call to get_commit_buffer. The buffer may or may not be
* freed by this call; callers should not access the memory afterwards.
*/
voidunuse_commit_buffer(conststructcommit*, constvoid*buffer);
/*
* Free any cached object buffer associated with the commit.
*/
voidfree_commit_buffer(structcommit*);
/*
* Disassociate any cached object buffer from the commit, but do not free it.
* The buffer (or NULL, if none) is returned.
*/
constvoid*detach_commit_buffer(structcommit*, unsigned long*sizep);
/* 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);
/* Shallow copy of the input list */
structcommit_list*copy_commit_list(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 {
/*
* Callers should tweak these to change the behavior of pp_* functions.
*/
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;
structident_split*from_ident;
/*
* Fields below here are manipulated internally by pp_* functions and
* should not be counted on by callers.
*/
structstring_listin_body_headers;
};
structuserformat_want {
unsignednotes:1;
};
externinthas_non_ascii(constchar*text);
structrev_info; /* in revision.h, it circularly uses enum cmit_fmt */
externconstchar*logmsg_reencode(conststructcommit*commit,
char**commit_encoding,
constchar*output_encoding);
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(structpretty_print_context*pp,
conststructcommit*commit,
structstrbuf*sb);
externvoidpp_commit_easy(enumcmit_fmtfmt, conststructcommit*commit,
structstrbuf*sb);
voidpp_user_info(structpretty_print_context*pp,
constchar*what, structstrbuf*sb,
constchar*line, constchar*encoding);
voidpp_title_line(structpretty_print_context*pp,
constchar**msg_p,
structstrbuf*sb,
constchar*encoding,
intneed_8bit_cte);
voidpp_remainder(structpretty_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_many(intnr, structcommit**commit, unsigned intmark);
voidclear_commit_marks_for_object_array(structobject_array*a, unsignedmark);
enumrev_sort_order {
REV_SORT_IN_GRAPH_ORDER=0,
REV_SORT_BY_COMMIT_DATE,
REV_SORT_BY_AUTHOR_DATE
};
/*
* Performs an in-place topological sort of list supplied.
*
* invariant of resulting list is:
* a reachable from b => ord(b) < ord(a)
* sort_order further specifies:
* REV_SORT_IN_GRAPH_ORDER: try to show a commit on a single-parent
* chain together.
* REV_SORT_BY_COMMIT_DATE: show eligible commits in committer-date order.
*/
voidsort_in_topological_order(structcommit_list**, enumrev_sort_order);
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 positive number a signed 32-bit integer can contain */
#defineINFINITE_DEPTH 0x7fffffff
structsha1_array;
structref;
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);
externvoidcheck_shallow_file_for_update(void);
externvoidset_alternate_shallow_file(constchar*path, intoverride);
externintwrite_shallow_commits(structstrbuf*out, intuse_pack_protocol,
conststructsha1_array*extra);
externvoidsetup_alternate_shallow(structlock_file*shallow_lock,
constchar**alternate_shallow_file,
conststructsha1_array*extra);
externconstchar*setup_temporary_shallow(conststructsha1_array*extra);
externvoidadvertise_shallow_grafts(int);
structshallow_info {
structsha1_array*shallow;
int*ours, nr_ours;
int*theirs, nr_theirs;
structsha1_array*ref;
/* for receive-pack */
uint32_t**used_shallow;
int*need_reachability_test;
int*reachable;
int*shallow_ref;
structcommit**commits;
intnr_commits;
};
externvoidprepare_shallow_info(structshallow_info*, structsha1_array*);
externvoidclear_shallow_info(structshallow_info*);
externvoidremove_nonexistent_theirs_shallow(structshallow_info*);
externvoidassign_shallow_commits_to_refs(structshallow_info*info,
uint32_t**used,
int*ref_status);
externintdelayed_reachability_test(structshallow_info*si, intc);
externvoidprune_shallow(intshow_only);
externstructtrace_keytrace_shallow;
intis_descendant_of(structcommit*, structcommit_list*);
intin_merge_bases(structcommit*, structcommit*);
intin_merge_bases_many(structcommit*, int, structcommit**);
externintinteractive_add(intargc, constchar**argv, constchar*prefix, intpatch);
externintrun_add_interactive(constchar*revision, constchar*patch_mode,
conststructpathspec*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(constchar*msg, size_tmsg_len,
constunsigned char*tree,
structcommit_list*parents, unsigned char*ret,
constchar*author, constchar*sign_commit);
externintcommit_tree_extended(constchar*msg, size_tmsg_len,
constunsigned 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);
typedefvoid (*each_mergetag_fn)(structcommit*commit, structcommit_extra_header*extra,
void*cb_data);
externvoidfor_each_mergetag(each_mergetag_fnfn, structcommit*commit, void*data);
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(conststructcommit*commit,
structstrbuf*message, structstrbuf*signature);
externintremove_signature(structstrbuf*buf);
externvoidprint_commit_list(structcommit_list*list,
constchar*format_cur,
constchar*format_last);
/*
* Check the signature of the given commit. The result of the check is stored
* in sig->check_result, 'G' for a good signature, 'U' for a good signature
* from an untrusted signer, 'B' for a bad signature and 'N' for no signature
* at all. This may allocate memory for sig->gpg_output, sig->gpg_status,
* sig->signer and sig->key.
*/
externvoidcheck_commit_signature(conststructcommit*commit, structsignature_check*sigc);
intcompare_commits_by_commit_date(constvoid*a_, constvoid*b_, void*unused);
LAST_ARG_MUST_BE_NULL
externintrun_commit_hook(inteditor_is_used, constchar*index_file, constchar*name, ...);
#endif/* COMMIT_H */