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