interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / replay.h

110 lines · 2946 bytes Raw Blame History
1#ifndef REPLAY_H
2#define REPLAY_H
3
4#include "hash.h"
5
6struct repository;
7struct rev_info;
8
9/*
10 * Controls what happens when a replayed commit becomes empty (i.e. its tree
11 * is identical to its parent's tree after the replay).
12 */
13enum replay_empty_commit_action {
14 /* Silently discard the empty commit. */
15 REPLAY_EMPTY_COMMIT_DROP,
16 /* Keep the empty commit as-is. */
17 REPLAY_EMPTY_COMMIT_KEEP,
18 /* Abort with an error. */
19 REPLAY_EMPTY_COMMIT_ABORT,
20};
21
22/*
23 * A set of options that can be passed to `replay_revisions()`.
24 */
25struct replay_revisions_options {
26 /*
27 * Starting point at which to create the new commits; must be a branch
28 * name. The branch will be updated to point to the rewritten commits.
29 * This option is mutually exclusive with `onto` and `revert`.
30 */
31 const char *advance;
32
33 /*
34 * Starting point at which to create the new commits; must be a
35 * committish. References pointing at descendants of `onto` will be
36 * updated to point to the new commits.
37 */
38 const char *onto;
39
40 /*
41 * Reference to update with the result of the replay. This will not
42 * update any refs from `onto`, `advance`, or `revert`. Ignores
43 * `contained`.
44 */
45 const char *ref;
46
47 /*
48 * Starting point at which to create revert commits; must be a branch
49 * name. The branch will be updated to point to the revert commits.
50 * This option is mutually exclusive with `onto` and `advance`.
51 */
52 const char *revert;
53
54 /*
55 * Update branches that point at commits in the given revision range.
56 * Requires `onto` to be set.
57 */
58 int contained;
59
60 /*
61 * Key used to sign newly-created commits. An empty string requests the
62 * default configured signing key, and NULL disables signing.
63 */
64 const char *sign_commit;
65
66 /*
67 * Controls what to do when a replayed commit becomes empty.
68 * Defaults to REPLAY_EMPTY_COMMIT_DROP.
69 */
70 enum replay_empty_commit_action empty;
71
72 /*
73 * Whether to linearize the commits (i.e. drop merge commits).
74 */
75 int linearize;
76};
77
78/* This struct is used as an out-parameter by `replay_revisions()`. */
79struct replay_result {
80 /*
81 * The set of reference updates that are caused by replaying the
82 * commits.
83 */
84 struct replay_ref_update {
85 char *refname;
86 struct object_id old_oid;
87 struct object_id new_oid;
88 } *updates;
89 size_t updates_nr, updates_alloc;
90};
91
92void replay_result_release(struct replay_result *result);
93
94void replay_result_queue_update(struct replay_result *result,
95 const char *refname,
96 const struct object_id *old_oid,
97 const struct object_id *new_oid);
98
99/*
100 * Replay a set of commits onto a new location. Leaves both the working tree,
101 * index and references untouched. Reference updates caused by the replay will
102 * be recorded in the `updates` out pointer.
103 *
104 * Returns 0 on success, 1 on conflict and a negative error code otherwise.
105 */
106int replay_revisions(struct rev_info *revs,
107 struct replay_revisions_options *opts,
108 struct replay_result *out);
109
110#endif