Files
git/replay.h
Toon Claes 23d83f8ddb replay: allow to specify a ref with option --ref
When option '--onto' is passed to git-replay(1), the command will update
refs from the <revision-range> passed to the command. When using option
'--advance' or '--revert', the argument of that option is a ref that
will be updated.

To enable users to specify which ref to update, add option '--ref'. When
using option '--ref', the refs described above are left untouched and
instead the argument of this option is updated instead.

Because this introduces code paths in replay.c that jump to `out` before
init_basic_merge_options() is called on `merge_opt`, zero-initialize the
struct.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-04-01 21:34:25 -07:00

76 lines
2.0 KiB
C

#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` and `revert`.
*/
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;
/*
* Reference to update with the result of the replay. This will not
* update any refs from `onto`, `advance`, or `revert`. Ignores
* `contained`.
*/
const char *ref;
/*
* Starting point at which to create revert commits; must be a branch
* name. The branch will be updated to point to the revert commits.
* This option is mutually exclusive with `onto` and `advance`.
*/
const char *revert;
/*
* 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