Skip to content

Commit

Permalink
commit-graph: when incompatible with graphs, indicate why
Browse files Browse the repository at this point in the history
When `gc.writeCommitGraph = true`, it is possible that the commit-graph
is _still_ not written: replace objects, grafts and shallow repositories
are incompatible with the commit-graph feature.

Under such circumstances, we need to indicate to the user why the
commit-graph was not written instead of staying silent about it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
dscho authored and gitster committed Feb 11, 2021
1 parent 773e25a commit c85eec7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,24 @@ static int commit_graph_compatible(struct repository *r)

if (read_replace_refs) {
prepare_replace_object(r);
if (hashmap_get_size(&r->objects->replace_map->map))
if (hashmap_get_size(&r->objects->replace_map->map)) {
warning(_("repository contains replace objects; "
"skipping commit-graph"));
return 0;
}
}

prepare_commit_graft(r);
if (r->parsed_objects &&
(r->parsed_objects->grafts_nr || r->parsed_objects->substituted_parent))
(r->parsed_objects->grafts_nr || r->parsed_objects->substituted_parent)) {
warning(_("repository contains (deprecated) grafts; "
"skipping commit-graph"));
return 0;
if (is_repository_shallow(r))
}
if (is_repository_shallow(r)) {
warning(_("repository is shallow; skipping commit-graph"));
return 0;
}

return 1;
}
Expand Down

0 comments on commit c85eec7

Please sign in to comment.