Code

577cfb33cdb1f2a830d8a8aa793723df8d7f76aa
[git.git] / notes-merge.h
1 #ifndef NOTES_MERGE_H
2 #define NOTES_MERGE_H
4 enum notes_merge_verbosity {
5         NOTES_MERGE_VERBOSITY_DEFAULT = 2,
6         NOTES_MERGE_VERBOSITY_MAX = 5
7 };
9 struct notes_merge_options {
10         const char *local_ref;
11         const char *remote_ref;
12         const char *commit_msg;
13         int verbosity;
14 };
16 void init_notes_merge_options(struct notes_merge_options *o);
18 /*
19  * Create new notes commit from the given notes tree
20  *
21  * Properties of the created commit:
22  * - tree: the result of converting t to a tree object with write_notes_tree().
23  * - parents: the given parents OR (if NULL) the commit referenced by t->ref.
24  * - author/committer: the default determined by commmit_tree().
25  * - commit message: msg
26  *
27  * The resulting commit SHA1 is stored in result_sha1.
28  */
29 void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
30                          const char *msg, unsigned char *result_sha1);
32 /*
33  * Merge notes from o->remote_ref into o->local_ref
34  *
35  * The given notes_tree 'local_tree' must be the notes_tree referenced by the
36  * o->local_ref. This is the notes_tree in which the object-level merge is
37  * performed.
38  *
39  * The commits given by the two refs are merged, producing one of the following
40  * outcomes:
41  *
42  * 1. The merge trivially results in an existing commit (e.g. fast-forward or
43  *    already-up-to-date). 'local_tree' is untouched, the SHA1 of the result
44  *    is written into 'result_sha1' and 0 is returned.
45  * 2. The merge successfully completes, producing a merge commit. local_tree
46  *    contains the updated notes tree, the SHA1 of the resulting commit is
47  *    written into 'result_sha1', and 1 is returned.
48  * 3. The merge fails. result_sha1 is set to null_sha1, and -1 is returned.
49  *
50  * Both o->local_ref and o->remote_ref must be given (non-NULL), but either ref
51  * (although not both) may refer to a non-existing notes ref, in which case
52  * that notes ref is interpreted as an empty notes tree, and the merge
53  * trivially results in what the other ref points to.
54  */
55 int notes_merge(struct notes_merge_options *o,
56                 struct notes_tree *local_tree,
57                 unsigned char *result_sha1);
59 #endif