🌐 AI搜索 & 代理 主页
blob: fc13de9780f98c3bd9f330ef6177fd47a4da3d80 [file] [log] [blame]
Daniel Barkalow6eb8ae02005-04-18 18:39:481#ifndef COMMIT_H
2#define COMMIT_H
3
4#include "object.h"
5#include "tree.h"
6
7struct commit_list {
8 struct commit *item;
9 struct commit_list *next;
10};
11
12struct commit {
13 struct object object;
Linus Torvaldsd3ff6f52006-06-18 01:26:1814 void *util;
Daniel Barkalow6eb8ae02005-04-18 18:39:4815 unsigned long date;
16 struct commit_list *parents;
17 struct tree *tree;
Linus Torvaldsbd1e17e2005-05-26 02:26:2818 char *buffer;
Daniel Barkalow6eb8ae02005-04-18 18:39:4819};
20
Linus Torvalds60ab26d2005-09-15 21:43:1721extern int save_commit_buffer;
Daniel Barkalow6eb8ae02005-04-18 18:39:4822extern const char *commit_type;
23
Jason McMullan5d6ccf52005-06-03 15:05:3924struct commit *lookup_commit(const unsigned char *sha1);
25struct commit *lookup_commit_reference(const unsigned char *sha1);
Junio C Hamanof76412e2005-08-21 09:51:1026struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
27 int quiet);
Daniel Barkalow6eb8ae02005-04-18 18:39:4828
Nicolas Pitrebd2c39f2005-05-06 17:48:3429int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
30
Daniel Barkalow6eb8ae02005-04-18 18:39:4831int parse_commit(struct commit *item);
32
Linus Torvaldsac5155e2005-05-31 01:44:0233struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p);
Linus Torvaldsf7554942005-07-06 16:31:1734struct commit_list * insert_by_date(struct commit *item, struct commit_list **list);
Daniel Barkalowdd97f852005-04-24 01:47:2335
Daniel Barkalow6eb8ae02005-04-18 18:39:4836void free_commit_list(struct commit_list *list);
37
Daniel Barkalowdd97f852005-04-24 01:47:2338void sort_by_date(struct commit_list **list);
39
Linus Torvalds000182e2005-06-05 16:02:0340/* Commit formats */
41enum cmit_fmt {
42 CMIT_FMT_RAW,
43 CMIT_FMT_MEDIUM,
44 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
Linus Torvalds9b66ec02005-06-27 00:50:4645 CMIT_FMT_SHORT,
46 CMIT_FMT_FULL,
Junio C Hamanoff56fe12005-11-10 06:15:2747 CMIT_FMT_FULLER,
Junio C Hamanod87449c2005-08-09 05:15:4048 CMIT_FMT_ONELINE,
Junio C Hamano3eefc182006-04-18 23:45:2749 CMIT_FMT_EMAIL,
Junio C Hamano6b9c58f2006-04-16 06:46:3650
51 CMIT_FMT_UNSPECIFIED,
Linus Torvalds000182e2005-06-05 16:02:0352};
53
Linus Torvalds9b66ec02005-06-27 00:50:4654extern enum cmit_fmt get_commit_format(const char *arg);
Jonas Fonseca3dfb9272006-08-28 13:52:1355extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date);
Linus Torvaldse3bc7a32005-06-01 15:34:2356
Daniel Barkalowdd97f852005-04-24 01:47:2357/** Removes the first commit from a list sorted by date, and adds all
58 * of its parents.
59 **/
Daniel Barkalow58e28af2005-04-24 03:29:2260struct commit *pop_most_recent_commit(struct commit_list **list,
61 unsigned int mark);
Daniel Barkalowdd97f852005-04-24 01:47:2362
jon@blackcubes.dyndns.orga3437b82005-06-06 15:39:4063struct commit *pop_commit(struct commit_list **stack);
64
Junio C Hamanof8f9c732006-01-08 02:52:4265void clear_commit_marks(struct commit *commit, unsigned int mark);
66
jon@blackcubes.dyndns.orga3437b82005-06-06 15:39:4067int count_parents(struct commit * commit);
Jon Seymourab580ac2005-07-06 16:39:3468
69/*
70 * Performs an in-place topological sort of list supplied.
71 *
Fredrik Kuivinen6b6dcfc2006-03-10 09:21:3772 * Pre-conditions for sort_in_topological_order:
Jon Seymourab580ac2005-07-06 16:39:3473 * all commits in input list and all parents of those
74 * commits must have object.util == NULL
Fredrik Kuivinen6b6dcfc2006-03-10 09:21:3775 *
76 * Pre-conditions for sort_in_topological_order_fn:
77 * all commits in input list and all parents of those
78 * commits must have getter(commit) == NULL
79 *
80 * Post-conditions:
Jon Seymourab580ac2005-07-06 16:39:3481 * invariant of resulting list is:
82 * a reachable from b => ord(b) < ord(a)
Junio C Hamano4c8725f2006-02-16 06:05:3383 * in addition, when lifo == 0, commits on parallel tracks are
84 * sorted in the dates order.
Jon Seymourab580ac2005-07-06 16:39:3485 */
Fredrik Kuivinen6b6dcfc2006-03-10 09:21:3786
87typedef void (*topo_sort_set_fn_t)(struct commit*, void *data);
88typedef void* (*topo_sort_get_fn_t)(struct commit*);
89
90void topo_sort_default_setter(struct commit *c, void *data);
91void *topo_sort_default_getter(struct commit *c);
92
Junio C Hamano4c8725f2006-02-16 06:05:3393void sort_in_topological_order(struct commit_list ** list, int lifo);
Fredrik Kuivinen6b6dcfc2006-03-10 09:21:3794void sort_in_topological_order_fn(struct commit_list ** list, int lifo,
95 topo_sort_set_fn_t setter,
96 topo_sort_get_fn_t getter);
Junio C Hamano5040f172006-04-07 06:58:5197
98struct commit_graft {
99 unsigned char sha1[20];
100 int nr_parent;
101 unsigned char parent[FLEX_ARRAY][20]; /* more */
102};
103
104struct commit_graft *read_graft_line(char *buf, int len);
105int register_commit_graft(struct commit_graft *, int);
106int read_graft_file(const char *graft_file);
107
Rene Scharfec0fa8252006-07-02 09:49:38108extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup);
Johannes Schindelin7c6f8aa2006-06-29 13:17:32109
Daniel Barkalow6eb8ae02005-04-18 18:39:48110#endif /* COMMIT_H */