git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] commit-graph: when incompatible with graphs, indicate why

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 11, 2021, 15:39 UTC
Message-ID
<pull.875.git.1613057954213.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
    Be clear why commit-graph was skipped
    
    After repairing my local checkout
    [https://github.com/gitgitgadget/git/pull/873], I was puzzled that the
    commit-graph file was not written. Turns out that I still had almost a
    dozen replace objects. But I only found out that they were blocking the
    commit-graph when I stepped through git gc in a debugger. This is my
    attempt to make it more straight-forward to recover from similar
    situations in the future.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-875%2Fdscho%2Fwarn-if-commit-graph-is-skipped-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-875/dscho/warn-if-commit-graph-is-skipped-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/875
 commit-graph.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/commit-graph.c b/commit-graph.c
index 65410602714e..9ad176fa7c8e 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -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;
 }

base-commit: f9f2520108bab26a750bcbb00518dc27672cf0a2
-- 
gitgitgadget
Next: Derrick Stolee
Message 1 of 4 in “commit-graph: when incompatible with graphs, indicate why”
  1. commit-graph: when incompatible with graphs, indicate whyJohannes Schindelin via GitGitGadget, Feb 11, 2021
  2. Derrick StoleeFeb 11, 2021
  3. Junio C HamanoFeb 11, 2021
  4. noisy "warning: repository contains (deprecated) grafts; skipping commit-graph" warningsÆvar Arnfjörð Bjarmason, Feb 25, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.