]> git.ipfire.org Git - thirdparty/git.git/blame - notes-merge.h
Merge branch 'jk/add-ignore-errors-bit-assignment-fix'
[thirdparty/git.git] / notes-merge.h
CommitLineData
75ef3f4a
JH
1#ifndef NOTES_MERGE_H
2#define NOTES_MERGE_H
3
4d03dd18 4#include "notes-utils.h"
ef3ca954
EN
5#include "strbuf.h"
6
7struct commit;
8struct object_id;
5684200f 9struct repository;
4d03dd18 10
809f38c8
JH
11#define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
12
75ef3f4a
JH
13enum notes_merge_verbosity {
14 NOTES_MERGE_VERBOSITY_DEFAULT = 2,
15 NOTES_MERGE_VERBOSITY_MAX = 5
16};
17
18struct notes_merge_options {
5684200f 19 struct repository *repo;
75ef3f4a
JH
20 const char *local_ref;
21 const char *remote_ref;
443259cf 22 struct strbuf commit_msg;
75ef3f4a 23 int verbosity;
4d03dd18 24 enum notes_merge_strategy strategy;
809f38c8 25 unsigned has_worktree:1;
75ef3f4a
JH
26};
27
5684200f
NTND
28void init_notes_merge_options(struct repository *r,
29 struct notes_merge_options *o);
75ef3f4a
JH
30
31/*
32 * Merge notes from o->remote_ref into o->local_ref
33 *
2085b16a
JH
34 * The given notes_tree 'local_tree' must be the notes_tree referenced by the
35 * o->local_ref. This is the notes_tree in which the object-level merge is
36 * performed.
37 *
75ef3f4a
JH
38 * The commits given by the two refs are merged, producing one of the following
39 * outcomes:
40 *
41 * 1. The merge trivially results in an existing commit (e.g. fast-forward or
5237e0eb
BW
42 * already-up-to-date). 'local_tree' is untouched, the OID of the result
43 * is written into 'result_oid' and 0 is returned.
2085b16a 44 * 2. The merge successfully completes, producing a merge commit. local_tree
5237e0eb
BW
45 * contains the updated notes tree, the OID of the resulting commit is
46 * written into 'result_oid', and 1 is returned.
809f38c8
JH
47 * 3. The merge results in conflicts. This is similar to #2 in that the
48 * partial merge result (i.e. merge result minus the unmerged entries)
5237e0eb 49 * are stored in 'local_tree', and the OID or the resulting commit
809f38c8 50 * (to be amended when the conflicts have been resolved) is written into
5237e0eb 51 * 'result_oid'. The unmerged entries are written into the
809f38c8
JH
52 * .git/NOTES_MERGE_WORKTREE directory with conflict markers.
53 * -1 is returned.
75ef3f4a
JH
54 *
55 * Both o->local_ref and o->remote_ref must be given (non-NULL), but either ref
56 * (although not both) may refer to a non-existing notes ref, in which case
57 * that notes ref is interpreted as an empty notes tree, and the merge
58 * trivially results in what the other ref points to.
59 */
60int notes_merge(struct notes_merge_options *o,
2085b16a 61 struct notes_tree *local_tree,
5237e0eb 62 struct object_id *result_oid);
75ef3f4a 63
6abb3655
JH
64/*
65 * Finalize conflict resolution from an earlier notes_merge()
66 *
67 * The given notes tree 'partial_tree' must be the notes_tree corresponding to
68 * the given 'partial_commit', the partial result commit created by a previous
69 * call to notes_merge().
70 *
71 * This function will add the (now resolved) notes in .git/NOTES_MERGE_WORKTREE
5237e0eb
BW
72 * to 'partial_tree', and create a final notes merge commit, the OID of which
73 * will be stored in 'result_oid'.
6abb3655
JH
74 */
75int notes_merge_commit(struct notes_merge_options *o,
76 struct notes_tree *partial_tree,
77 struct commit *partial_commit,
5237e0eb 78 struct object_id *result_oid);
6abb3655
JH
79
80/*
81 * Abort conflict resolution from an earlier notes_merge()
82 *
83 * Removes the notes merge worktree in .git/NOTES_MERGE_WORKTREE.
84 */
85int notes_merge_abort(struct notes_merge_options *o);
86
75ef3f4a 87#endif