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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]