fuzz: link fuzz programs with `make all` on Linux
[alt-git.git] / notes-merge.h
blob99f9c709c536ac19c677e97348e9924c2764d217
1 #ifndef NOTES_MERGE_H
2 #define NOTES_MERGE_H
4 #include "notes-utils.h"
5 #include "strbuf.h"
7 struct commit;
8 struct object_id;
9 struct repository;
11 #define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
13 enum notes_merge_verbosity {
14 NOTES_MERGE_VERBOSITY_DEFAULT = 2,
15 NOTES_MERGE_VERBOSITY_MAX = 5
18 struct notes_merge_options {
19 struct repository *repo;
20 const char *local_ref;
21 const char *remote_ref;
22 struct strbuf commit_msg;
23 int verbosity;
24 enum notes_merge_strategy strategy;
25 unsigned has_worktree:1;
28 void init_notes_merge_options(struct repository *r,
29 struct notes_merge_options *o);
32 * Merge notes from o->remote_ref into o->local_ref
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.
38 * The commits given by the two refs are merged, producing one of the following
39 * outcomes:
41 * 1. The merge trivially results in an existing commit (e.g. fast-forward or
42 * already-up-to-date). 'local_tree' is untouched, the OID of the result
43 * is written into 'result_oid' and 0 is returned.
44 * 2. The merge successfully completes, producing a merge commit. local_tree
45 * contains the updated notes tree, the OID of the resulting commit is
46 * written into 'result_oid', and 1 is returned.
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)
49 * are stored in 'local_tree', and the OID or the resulting commit
50 * (to be amended when the conflicts have been resolved) is written into
51 * 'result_oid'. The unmerged entries are written into the
52 * .git/NOTES_MERGE_WORKTREE directory with conflict markers.
53 * -1 is returned.
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.
60 int notes_merge(struct notes_merge_options *o,
61 struct notes_tree *local_tree,
62 struct object_id *result_oid);
65 * Finalize conflict resolution from an earlier notes_merge()
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().
71 * This function will add the (now resolved) notes in .git/NOTES_MERGE_WORKTREE
72 * to 'partial_tree', and create a final notes merge commit, the OID of which
73 * will be stored in 'result_oid'.
75 int notes_merge_commit(struct notes_merge_options *o,
76 struct notes_tree *partial_tree,
77 struct commit *partial_commit,
78 struct object_id *result_oid);
81 * Abort conflict resolution from an earlier notes_merge()
83 * Removes the notes merge worktree in .git/NOTES_MERGE_WORKTREE.
85 int notes_merge_abort(struct notes_merge_options *o);
87 #endif