Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v5 1/7] replace: forbid replacing an object with one of a different type

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:58:39

Christian Couder [off-list ref] writes:
+	obj_type = sha1_object_info(object, NULL);
+	repl_type = sha1_object_info(repl, NULL);
That we can do this is somewhat curious.  If an object is replaced
with a different one, would it mean that this code snippet is
totally bogus?

        type1 = sha1_object_info(sha1, &size1);
        area = xmalloc(size1);
        orig = read_sha1_file(sha1, &type0, &size0);
	memcpy(area, orig, size1);
	free(orig);
+	if (!force && obj_type != repl_type)
+		die("Objects must be of the same type.\n"
+		    "'%s' points to a replaced object of type '%s'\n"
+		    "while '%s' points to a replacement object of type '%s'.",
+		    object_ref, typename(obj_type),
+		    replace_ref, typename(repl_type));
+
 	if (read_ref(ref, prev))
 		hashclr(prev);
 	else if (!force)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help