Junio C Hamano <gits...@pobox.com> writes:

> Christian Couder <chrisc...@tuxfamily.org> writes:
>> Users replacing an object with one of a different type were not
>> prevented to do so, even if it was obvious, and stated in the doc,
>> that bad things would result from doing that.
>> To avoid mistakes, it is better to just forbid that though.
>> There is no case where one object can be replaced with one of a
>> different type while keeping the history valid, because:
>> * Annotated tags contain the type of the tagged object.
> If you replace the tagged object and the tag at the same time,
> wouldn't that make the resulting history valid again?
> Granted, there may not be a strong reason to reuse the object name
> of the tagged object in such a case, but this "there may not be" is
> merely "I do not think of offhand", so I am not sure what workflow
> of other people we are breaking with this change.  A light-weight
> tag may already point at the tagged object (in other words, the
> object name of the tagged object is known to the outside world) and
> that could be a reason why you would need to reuse the object name
> of that object while changing its type.
> I dunno.

Hrm, you're right, that's a flaw in my logic.  You could do the same in
all other cases too, e.g. replace a tree so that an entry is of a
different type and at the same time change the type of the object
itself.  You however have to carefully go through all objects that refer
to the one that was replaced, and fix the type in all of them.

It still seems an extremely unsafe thing to do with trees: especially
for small trees there is a small probability that you will generate the
same tree again in the future (by having the same blobs in the directory
again) and record it as a subtree or the 'tree' field of a commit.  The
history would then again be invalid.

Should we add a --force flag of some sort to allow the user to do this,
while keeping the normal safety checks?

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

Reply via email to