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

Function try_to_simplify_commit

revision.c:963–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

961}
962
963static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
964{
965 struct commit_list **pp, *parent;
966 struct treesame_state *ts = NULL;
967 int relevant_change = 0, irrelevant_change = 0;
968 int relevant_parents, nth_parent;
969
970 /*
971 * If we don't do pruning, everything is interesting
972 */
973 if (!revs->prune)
974 return;
975
976 if (!repo_get_commit_tree(the_repository, commit))
977 return;
978
979 if (!commit->parents) {
980 /*
981 * Pretend as if we are comparing ourselves to the
982 * (non-existent) first parent of this commit object. Even
983 * though no such parent exists, its changed-path Bloom filter
984 * (if one exists) is relative to the empty tree, using Bloom
985 * filters is allowed here.
986 */
987 if (rev_same_tree_as_empty(revs, commit, 0))
988 commit->object.flags |= TREESAME;
989 return;
990 }
991
992 /*
993 * Normal non-merge commit? If we don't want to make the
994 * history dense, we consider it always to be a change..
995 */
996 if (!revs->dense && !commit->parents->next)
997 return;
998
999 for (pp = &commit->parents, nth_parent = 0, relevant_parents = 0;
1000 (parent = *pp) != NULL;
1001 pp = &parent->next, nth_parent++) {
1002 struct commit *p = parent->item;
1003 if (relevant_commit(p))
1004 relevant_parents++;
1005
1006 if (nth_parent == 1) {
1007 /*
1008 * This our second loop iteration - so we now know
1009 * we're dealing with a merge.
1010 *
1011 * Do not compare with later parents when we care only about
1012 * the first parent chain, in order to avoid derailing the
1013 * traversal to follow a side branch that brought everything
1014 * in the path we are limited to by the pathspec.
1015 */
1016 if (revs->first_parent_only)
1017 break;
1018 /*
1019 * If this will remain a potentially-simplifiable
1020 * merge, remember per-parent treesame if needed.

Callers 2

process_parentsFunction · 0.85
get_revision_1Function · 0.85

Calls 10

repo_get_commit_treeFunction · 0.85
rev_same_tree_as_emptyFunction · 0.85
relevant_commitFunction · 0.85
initialise_treesameFunction · 0.85
repo_parse_commitFunction · 0.85
oid_to_hexFunction · 0.85
rev_compare_treeFunction · 0.85
commit_list_freeFunction · 0.85
pop_commitFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected