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