MCPcopy Index your code
hub / github.com/git/git / pick_regular_commit

Function pick_regular_commit

replay.c:266–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266static struct commit *pick_regular_commit(struct repository *repo,
267 struct commit *pickme,
268 kh_oid_map_t *replayed_commits,
269 struct commit *onto,
270 struct merge_options *merge_opt,
271 struct merge_result *result,
272 enum replay_mode mode,
273 enum replay_empty_commit_action empty)
274{
275 struct commit *base, *replayed_base;
276 struct tree *pickme_tree, *base_tree, *replayed_base_tree;
277
278 if (pickme->parents) {
279 base = pickme->parents->item;
280 base_tree = repo_get_commit_tree(repo, base);
281 } else {
282 base = NULL;
283 base_tree = lookup_tree(repo, repo->hash_algo->empty_tree);
284 }
285
286 replayed_base = mapped_commit(replayed_commits, base, onto);
287 replayed_base_tree = repo_get_commit_tree(repo, replayed_base);
288 pickme_tree = repo_get_commit_tree(repo, pickme);
289
290 if (mode == REPLAY_MODE_PICK) {
291 /* Cherry-pick: normal order */
292 merge_opt->branch1 = short_commit_name(repo, replayed_base);
293 merge_opt->branch2 = short_commit_name(repo, pickme);
294 if (pickme->parents)
295 merge_opt->ancestor = xstrfmt("parent of %s", merge_opt->branch2);
296 else
297 merge_opt->ancestor = xstrdup("empty tree");
298
299 merge_incore_nonrecursive(merge_opt,
300 base_tree,
301 replayed_base_tree,
302 pickme_tree,
303 result);
304
305 free((char *)merge_opt->ancestor);
306 } else if (mode == REPLAY_MODE_REVERT) {
307 /* Revert: swap base and pickme to reverse the diff */
308 const char *pickme_name = short_commit_name(repo, pickme);
309 merge_opt->branch1 = short_commit_name(repo, replayed_base);
310 merge_opt->branch2 = xstrfmt("parent of %s", pickme_name);
311 merge_opt->ancestor = pickme_name;
312
313 merge_incore_nonrecursive(merge_opt,
314 pickme_tree,
315 replayed_base_tree,
316 base_tree,
317 result);
318
319 free((char *)merge_opt->branch2);
320 } else {
321 BUG("unexpected replay mode %d", mode);
322 }
323 merge_opt->ancestor = NULL;

Callers 1

replay_revisionsFunction · 0.85

Calls 11

repo_get_commit_treeFunction · 0.85
lookup_treeFunction · 0.85
mapped_commitFunction · 0.85
xstrfmtFunction · 0.85
xstrdupFunction · 0.85
oideqFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
create_commitFunction · 0.85
short_commit_nameFunction · 0.70

Tested by

no test coverage detected