Re: [PATCH v5 1/7] replace: forbid replacing an object with one of a different type
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 6, 2013, 20:29 UTC
- Message-ID
- <xmqqmwnpwv6m.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <20130906051100.6657.41248.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> 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);Show 10 quoted lines
> + 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)