builtin/notes.c: Refactor creation of notes commits.
[git.git] / notes-merge.h
blob49e1b3a0f2fb1386b3c608e9b5df7f5d7e7586c1
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 int verbosity;
15 void init_notes_merge_options(struct notes_merge_options *o);
18 * Create new notes commit from the given notes tree
20 * Properties of the created commit:
21 * - tree: the result of converting t to a tree object with write_notes_tree().
22 * - parents: the given parents OR (if NULL) the commit referenced by t->ref.
23 * - author/committer: the default determined by commmit_tree().
24 * - commit message: msg
26 * The resulting commit SHA1 is stored in result_sha1.
28 void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
29 const char *msg, unsigned char *result_sha1);
32 * Merge notes from o->remote_ref into o->local_ref
34 * The commits given by the two refs are merged, producing one of the following
35 * outcomes:
37 * 1. The merge trivially results in an existing commit (e.g. fast-forward or
38 * already-up-to-date). The SHA1 of the result is written into 'result_sha1'
39 * and 0 is returned.
40 * 2. The merge fails. result_sha1 is set to null_sha1, and non-zero returned.
42 * Both o->local_ref and o->remote_ref must be given (non-NULL), but either ref
43 * (although not both) may refer to a non-existing notes ref, in which case
44 * that notes ref is interpreted as an empty notes tree, and the merge
45 * trivially results in what the other ref points to.
47 int notes_merge(struct notes_merge_options *o,
48 unsigned char *result_sha1);
50 #endif