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

[RFC PATCH 4/6] commit-graph: avoid writing when repo is shallow

From
Derrick Stolee <dstolee@microsoft.com>
Date
May 31, 2018, 17:41 UTC
Message-ID
<20180531174024.124488-5-dstolee@microsoft.com>
In-Reply-To
<20180531174024.124488-1-dstolee@microsoft.com>

Shallow clones do not interact well with the commit-graph feature for several reasons. Instead of doing the hard thing to fix those interactions, instead prevent reading or writing a commit-graph file for shallow repositories.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 commit-graph.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/commit-graph.c b/commit-graph.c
index 95af4ed519..80e377b90f 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -208,6 +208,9 @@ static void prepare_commit_graph(void)
 		return;
 	prepare_commit_graph_run_once = 1;
 
+	if (is_repository_shallow())
+		return;
+
 	obj_dir = get_object_directory();
 	prepare_commit_graph_one(obj_dir);
 	prepare_alt_odb();
@@ -711,6 +714,15 @@ void write_commit_graph(const char *obj_dir,
 	int num_extra_edges;
 	struct commit_list *parent;
 
+	/*
+	 * Shallow clones are not supproted, as they create bad
+	 * generation skips as they are un-shallowed.
+	 */
+	if (is_repository_shallow()) {
+		warning("writing a commit-graph in a shallow repository is not supported");
+		return;
+	}
+
 	oids.nr = 0;
 	oids.alloc = approximate_object_count() / 4;
 
-- 
2.16.2.338.gcfe06ae955
Previous: Derrick StoleeNext: Stefan Beller
Message 2 of 18 in “Fix commit-graph/graft/replace/shallow combo”
  1. 0/6 Fix commit-graph/graft/replace/shallow comboDerrick Stolee, May 31, 2018
  2. 4/6 commit-graph: avoid writing when repo is shallowDerrick Stolee, May 31, 2018
  3. Stefan BellerMay 31, 2018
  4. Junio C HamanoJun 1, 2018
  5. Derrick StoleeJun 1, 2018
  6. Jakub NarebskiJun 2, 2018
  7. Junio C HamanoJun 4, 2018
  8. 1/6 DO NOT MERGE: compute commit-graph on every commitDerrick Stolee, May 31, 2018
  9. Stefan BellerMay 31, 2018
  10. 5/6 fetch: destroy commit graph on shallow parametersDerrick Stolee, May 31, 2018
  11. Stefan BellerMay 31, 2018
  12. 2/6 DO NOT MERGE: write commit-graph on every fetchDerrick Stolee, May 31, 2018
  13. 3/6 commit-graph: enable replace-object and graftsDerrick Stolee, May 31, 2018
  14. Jakub NarebskiJun 9, 2018
  15. 6/6 commit-graph: revert to odb on missing parentsDerrick Stolee, May 31, 2018
  16. Stefan BellerMay 31, 2018
  17. Derrick StoleeJun 1, 2018
  18. Jakub NarebskiJun 8, 2018

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.