Skip to content

Commit c85eec7

Browse files
dschogitster
authored andcommitted
commit-graph: when incompatible with graphs, indicate why
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 <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 773e25a commit c85eec7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

commit-graph.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,24 @@ static int commit_graph_compatible(struct repository *r)
205205

206206
if (read_replace_refs) {
207207
prepare_replace_object(r);
208-
if (hashmap_get_size(&r->objects->replace_map->map))
208+
if (hashmap_get_size(&r->objects->replace_map->map)) {
209+
warning(_("repository contains replace objects; "
210+
"skipping commit-graph"));
209211
return 0;
212+
}
210213
}
211214

212215
prepare_commit_graft(r);
213216
if (r->parsed_objects &&
214-
(r->parsed_objects->grafts_nr || r->parsed_objects->substituted_parent))
217+
(r->parsed_objects->grafts_nr || r->parsed_objects->substituted_parent)) {
218+
warning(_("repository contains (deprecated) grafts; "
219+
"skipping commit-graph"));
215220
return 0;
216-
if (is_repository_shallow(r))
221+
}
222+
if (is_repository_shallow(r)) {
223+
warning(_("repository is shallow; skipping commit-graph"));
217224
return 0;
225+
}
218226

219227
return 1;
220228
}

0 commit comments

Comments
 (0)