From: Junio C Hamano Date: Fri, 06 Sep 2013 20:29:21 GMT Subject: Re: [PATCH v5 1/7] replace: forbid replacing an object with one of a different type Message-ID: In-Reply-To: <20130906051100.6657.41248.chriscool@tuxfamily.org> Christian Couder 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)