blob: 70a7c75e6590ae7f8eef50f91a495fc6138fda4a [file] [log] [blame]
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -07001#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;
14 unsigned long date;
15 struct commit_list *parents;
16 struct tree *tree;
Linus Torvaldsbd1e17e2005-05-25 19:26:28 -070017 char *buffer;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070018};
19
Linus Torvalds60ab26d2005-09-15 14:43:17 -070020extern int save_commit_buffer;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070021extern const char *commit_type;
22
Jason McMullan5d6ccf52005-06-03 11:05:39 -040023struct commit *lookup_commit(const unsigned char *sha1);
24struct commit *lookup_commit_reference(const unsigned char *sha1);
Junio C Hamanof76412e2005-08-21 02:51:10 -070025struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
26 int quiet);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070027
Nicolas Pitrebd2c39f2005-05-06 13:48:34 -040028int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
29
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070030int parse_commit(struct commit *item);
31
Linus Torvaldsac5155e2005-05-30 18:44:02 -070032struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p);
Linus Torvaldsf7554942005-07-06 09:31:17 -070033struct commit_list * insert_by_date(struct commit *item, struct commit_list **list);
Daniel Barkalowdd97f852005-04-23 18:47:23 -070034
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070035void free_commit_list(struct commit_list *list);
36
Daniel Barkalowdd97f852005-04-23 18:47:23 -070037void sort_by_date(struct commit_list **list);
38
Linus Torvalds000182e2005-06-05 09:02:03 -070039/* Commit formats */
40enum cmit_fmt {
41 CMIT_FMT_RAW,
42 CMIT_FMT_MEDIUM,
43 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
Linus Torvalds9b66ec02005-06-26 17:50:46 -070044 CMIT_FMT_SHORT,
45 CMIT_FMT_FULL,
Junio C Hamanoff56fe12005-11-09 22:15:27 -080046 CMIT_FMT_FULLER,
Junio C Hamanod87449c2005-08-08 22:15:40 -070047 CMIT_FMT_ONELINE,
Linus Torvalds000182e2005-06-05 09:02:03 -070048};
49
Linus Torvalds9b66ec02005-06-26 17:50:46 -070050extern enum cmit_fmt get_commit_format(const char *arg);
Junio C Hamano3815f422006-01-27 01:54:59 -080051extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev);
Linus Torvaldse3bc7a32005-06-01 08:34:23 -070052
Daniel Barkalowdd97f852005-04-23 18:47:23 -070053/** Removes the first commit from a list sorted by date, and adds all
54 * of its parents.
55 **/
Daniel Barkalow58e28af2005-04-23 20:29:22 -070056struct commit *pop_most_recent_commit(struct commit_list **list,
57 unsigned int mark);
Daniel Barkalowdd97f852005-04-23 18:47:23 -070058
jon@blackcubes.dyndns.orga3437b82005-06-06 15:39:40 +000059struct commit *pop_commit(struct commit_list **stack);
60
Junio C Hamanof8f9c732006-01-07 18:52:42 -080061void clear_commit_marks(struct commit *commit, unsigned int mark);
62
jon@blackcubes.dyndns.orga3437b82005-06-06 15:39:40 +000063int count_parents(struct commit * commit);
Jon Seymourab580ac2005-07-07 02:39:34 +100064
65/*
66 * Performs an in-place topological sort of list supplied.
67 *
68 * Pre-conditions:
69 * all commits in input list and all parents of those
70 * commits must have object.util == NULL
71 *
72 * Post-conditions:
73 * invariant of resulting list is:
74 * a reachable from b => ord(b) < ord(a)
Junio C Hamano4c8725f2006-02-15 22:05:33 -080075 * in addition, when lifo == 0, commits on parallel tracks are
76 * sorted in the dates order.
Jon Seymourab580ac2005-07-07 02:39:34 +100077 */
Junio C Hamano4c8725f2006-02-15 22:05:33 -080078void sort_in_topological_order(struct commit_list ** list, int lifo);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070079#endif /* COMMIT_H */