mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-13 08:57:56 -05:00
replay: add helper to put entry into mapped_commits
The function replay_revisions() in replay.c is rather lengthy. Extract the logic to put a commit entry into mapped_commits into a helper function put_mapped_commit(). While at it, rename mapped_commit() to get_mapped_commit() to pair with this new function. Signed-off-by: Toon Claes <toon@iotcl.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
ea0af2fe30
commit
dbec23af84
31
replay.c
31
replay.c
@@ -243,9 +243,9 @@ static void set_up_replay_mode(struct repository *repo,
|
||||
strset_clear(&rinfo.positive_refs);
|
||||
}
|
||||
|
||||
static struct commit *mapped_commit(kh_oid_map_t *replayed_commits,
|
||||
struct commit *commit,
|
||||
struct commit *fallback)
|
||||
static struct commit *get_mapped_commit(kh_oid_map_t *replayed_commits,
|
||||
struct commit *commit,
|
||||
struct commit *fallback)
|
||||
{
|
||||
khint_t pos;
|
||||
if (!commit)
|
||||
@@ -256,6 +256,21 @@ static struct commit *mapped_commit(kh_oid_map_t *replayed_commits,
|
||||
return kh_value(replayed_commits, pos);
|
||||
}
|
||||
|
||||
static void put_mapped_commit(kh_oid_map_t *replayed_commits,
|
||||
struct commit *commit,
|
||||
struct commit *new_commit)
|
||||
{
|
||||
khint_t pos;
|
||||
int ret;
|
||||
|
||||
pos = kh_put_oid_map(replayed_commits, commit->object.oid, &ret);
|
||||
if (ret == 0)
|
||||
BUG("Duplicate rewritten commit: %s\n",
|
||||
oid_to_hex(&commit->object.oid));
|
||||
|
||||
kh_value(replayed_commits, pos) = new_commit;
|
||||
}
|
||||
|
||||
static struct commit *pick_regular_commit(struct repository *repo,
|
||||
struct commit *pickme,
|
||||
kh_oid_map_t *replayed_commits,
|
||||
@@ -276,7 +291,7 @@ static struct commit *pick_regular_commit(struct repository *repo,
|
||||
base_tree = lookup_tree(repo, repo->hash_algo->empty_tree);
|
||||
}
|
||||
|
||||
replayed_base = mapped_commit(replayed_commits, base, onto);
|
||||
replayed_base = get_mapped_commit(replayed_commits, base, onto);
|
||||
replayed_base_tree = repo_get_commit_tree(repo, replayed_base);
|
||||
pickme_tree = repo_get_commit_tree(repo, pickme);
|
||||
|
||||
@@ -414,8 +429,6 @@ int replay_revisions(struct rev_info *revs,
|
||||
replayed_commits = kh_init_oid_map();
|
||||
while ((commit = get_revision(revs))) {
|
||||
const struct name_decoration *decoration;
|
||||
khint_t pos;
|
||||
int hr;
|
||||
|
||||
if (commit->parents && commit->parents->next)
|
||||
die(_("replaying merge commits is not supported yet!"));
|
||||
@@ -427,11 +440,7 @@ int replay_revisions(struct rev_info *revs,
|
||||
break;
|
||||
|
||||
/* Record commit -> last_commit mapping */
|
||||
pos = kh_put_oid_map(replayed_commits, commit->object.oid, &hr);
|
||||
if (hr == 0)
|
||||
BUG("Duplicate rewritten commit: %s\n",
|
||||
oid_to_hex(&commit->object.oid));
|
||||
kh_value(replayed_commits, pos) = last_commit;
|
||||
put_mapped_commit(replayed_commits, commit, last_commit);
|
||||
|
||||
/* Update any necessary branches */
|
||||
if (ref)
|
||||
|
||||
Reference in New Issue
Block a user