summaryrefslogtreecommitdiffstats
path: root/replay.h
blob: d8407dc7f710fca0014fe8a6bd2faaf85e62347c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef REPLAY_H
#define REPLAY_H

#include "hash.h"

struct repository;
struct rev_info;

/*
 * A set of options that can be passed to `replay_revisions()`.
 */
struct replay_revisions_options {
	/*
	 * Starting point at which to create the new commits; must be a branch
	 * name. The branch will be updated to point to the rewritten commits.
	 * This option is mutually exclusive with `onto`.
	 */
	const char *advance;

	/*
	 * Starting point at which to create the new commits; must be a
	 * committish. References pointing at decendants of `onto` will be
	 * updated to point to the new commits.
	 */
	 const char *onto;

	/*
	 * Update branches that point at commits in the given revision range.
	 * Requires `onto` to be set.
	 */
	int contained;
};

/* This struct is used as an out-parameter by `replay_revisions()`. */
struct replay_result {
	/*
	 * The set of reference updates that are caused by replaying the
	 * commits.
	 */
	struct replay_ref_update {
		char *refname;
		struct object_id old_oid;
		struct object_id new_oid;
	} *updates;
	size_t updates_nr, updates_alloc;
};

void replay_result_release(struct replay_result *result);

/*
 * Replay a set of commits onto a new location. Leaves both the working tree,
 * index and references untouched. Reference updates caused by the replay will
 * be recorded in the `updates` out pointer.
 *
 * Returns 0 on success, 1 on conflict and a negative error code otherwise.
 */
int replay_revisions(struct rev_info *revs,
		     struct replay_revisions_options *opts,
		     struct replay_result *out);

#endif