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

[PATCH 6/7] read-cache: refuse to create index referring to external objects

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 24, 2013, 08:42 UTC
Message-ID
<1359016940-18849-6-git-send-email-pclouds@gmail.com>
In-Reply-To
<1359016940-18849-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff --git a/read-cache.c b/read-cache.c
index fda78bc..4579215 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1720,6 +1720,26 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce,
 			      ce->name + common, ce_namelen(ce) - common);
 	}
 
+	if (object_database_contaminated) {
+		struct object_info oi;
+		switch (ce->ce_mode) {
+		case S_IFGITLINK:
+			break;
+		case S_IFDIR:
+			if (sha1_object_info_extended(ce->sha1, &oi) != OBJ_TREE ||
+			    (oi.alt && oi.alt->external))
+				die("cannot create index referring to an external tree %s",
+				    sha1_to_hex(ce->sha1));
+			break;
+		default:
+			if (sha1_object_info_extended(ce->sha1, &oi) != OBJ_BLOB ||
+				    (oi.alt && oi.alt->external))
+				die("cannot create index referring to an external blob %s",
+				    sha1_to_hex(ce->sha1));
+			break;
+		}
+	}
+
 	result = ce_write(c, fd, ondisk, size);
 	free(ondisk);
 	return result;
-- 
1.8.0.rc3.18.g0d9b108
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 6 of 21 in “sha1_file: keep track of where an SHA-1 object comes from”
  1. 1/7 sha1_file: keep track of where an SHA-1 object comes fromNguyễn Thái Ngọc Duy, Jan 24, 2013
  2. 2/7 sha1_file: separate alt object db from own repos and submodules'sNguyễn Thái Ngọc Duy, Jan 24, 2013
  3. 3/7 sha1_file: refuse to write commits referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  4. 4/7 sha1_file: refuse to write trees referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  5. 5/7 sha1_file: refuse to write tags referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  6. 6/7 read-cache: refuse to create index referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  7. Junio C HamanoJan 24, 2013
  8. Duy NguyenJan 25, 2013
  9. Junio C HamanoJan 25, 2013
  10. Duy NguyenJan 28, 2013
  11. Junio C HamanoJan 28, 2013
  12. Duy NguyenJan 28, 2013
  13. Junio C HamanoJan 28, 2013
  14. Duy NguyenJan 28, 2013
  15. Junio C HamanoJan 28, 2013
  16. Duy NguyenJan 28, 2013
  17. 7/7 refs: do not update ref(log) referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  18. Junio C HamanoJan 24, 2013
  19. Duy NguyenJan 25, 2013
  20. Junio C HamanoJan 25, 2013
  21. Duy NguyenJan 25, 2013

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.