{"thread":{"id":"34785","subject":"[PATCH v2 4/5] t6050-replace: add test to clean up all the replace refs","startedAt":"2013-08-27T19:48:22Z","lastAt":"2013-08-30T16:52:55Z","messageCount":13,"participants":["Christian Couder","Junio C Hamano","Thomas Rast"],"isPatch":true,"patchVersion":2,"patchTotal":5},"messages":[{"id":"226053","messageId":"20130827194022.11172.56453.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":null,"subject":"[PATCH v2 0/5] Check replacement object type and minor updates","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-27T19:48:22Z","receivedAt":"2013-08-27T19:48:22Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"The only changes compared to the previous version are those\nsuggested by Johannes:\n\n- the error message is now:\n\n\t\"Objects must be of the same type.\\n\"\n\t\"'%s' points to a replaced object of type '%s'\\n\"\n\t\"while '%s' points to a replacement object of type '%s'.\"\n\n- the test uses \".\" instead of \"'\\''\"\n\nOnly patchs 1/5 and 3/5 were changed.\n\nChristian Couder (5):\n  replace: forbid replacing an object with one of a different type\n  Documentation/replace: state that objects must be of the same type\n  t6050-replace: test that objects are of the same type\n  t6050-replace: add test to clean up all the replace refs\n  Documentation/replace: add Creating Replacement Objects section\n\n Documentation/git-replace.txt | 23 ++++++++++++++++++++---\n builtin/replace.c             | 10 ++++++++++\n t/t6050-replace.sh            | 19 +++++++++++++++++++\n 3 files changed, 49 insertions(+), 3 deletions(-)\n\n-- \n1.8.4.rc1.26.gdd51ee9\n"},{"id":"226055","messageId":"20130827194828.11172.73829.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":"20130827194022.11172.56453.chriscool@tuxfamily.org","subject":"[PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-27T19:48:23Z","receivedAt":"2013-08-27T19:48:23Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Users replacing an object with one of a different type were not\nprevented to do so, even if it was obvious, and stated in the doc,\nthat bad things would result from doing that.\n\nTo avoid mistakes, it is better to just forbid that though.\n\nThere is no case where one object can be replaced with one of a\ndifferent type while keeping the history valid, because:\n\n* Annotated tags contain the type of the tagged object.\n\n* The tree/parent lines in commits must be a tree and commits, resp.\n\n* The object types referred to by trees are specified in the 'mode'\n  field:\n    100644 and 100755    blob\n    160000               commit\n    040000               tree\n  (these are the only valid modes)\n\n* Blobs don't point at anything.\n\nThe doc will be updated in a later patch.\n\nAcked-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/replace.c | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 59d3115..9a94769 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -85,6 +85,7 @@ static int replace_object(const char *object_ref, const char *replace_ref,\n \t\t\t  int force)\n {\n \tunsigned char object[20], prev[20], repl[20];\n+\tenum object_type obj_type, repl_type;\n \tchar ref[PATH_MAX];\n \tstruct ref_lock *lock;\n \n@@ -100,6 +101,15 @@ static int replace_object(const char *object_ref, const char *replace_ref,\n \tif (check_refname_format(ref, 0))\n \t\tdie(\"'%s' is not a valid ref name.\", ref);\n \n+\tobj_type = sha1_object_info(object, NULL);\n+\trepl_type = sha1_object_info(repl, NULL);\n+\tif (obj_type != repl_type)\n+\t\tdie(\"Objects must be of the same type.\\n\"\n+\t\t    \"'%s' points to a replaced object of type '%s'\\n\"\n+\t\t    \"while '%s' points to a replacement object of type '%s'.\",\n+\t\t    object_ref, typename(obj_type),\n+\t\t    replace_ref, typename(repl_type));\n+\n \tif (read_ref(ref, prev))\n \t\thashclr(prev);\n \telse if (!force)\n-- \n1.8.4.rc1.26.gdd51ee9\n"},{"id":"226056","messageId":"20130827194828.11172.75730.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":"20130827194022.11172.56453.chriscool@tuxfamily.org","subject":"[PATCH v2 2/5] Documentation/replace: state that objects must be of the same type","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-27T19:48:24Z","receivedAt":"2013-08-27T19:48:24Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"A previous patch ensures that both the replaced and the replacement\nobjects passed to git replace must be of the same type.\n\nWhile at it state that there is no other restriction on both objects.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-replace.txt | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt\nindex e0b4057..aa66d27 100644\n--- a/Documentation/git-replace.txt\n+++ b/Documentation/git-replace.txt\n@@ -20,6 +20,9 @@ The name of the 'replace' reference is the SHA-1 of the object that is\n replaced. The content of the 'replace' reference is the SHA-1 of the\n replacement object.\n \n+The replaced object and the replacement object must be of the same type.\n+There is no other restriction on them.\n+\n Unless `-f` is given, the 'replace' reference must not yet exist.\n \n Replacement references will be used by default by all Git commands\n@@ -69,9 +72,7 @@ go back to a replaced commit will move the branch to the replacement\n commit instead of the replaced commit.\n \n There may be other problems when using 'git rev-list' related to\n-pending objects. And of course things may break if an object of one\n-type is replaced by an object of another type (for example a blob\n-replaced by a commit).\n+pending objects.\n \n SEE ALSO\n --------\n-- \n1.8.4.rc1.26.gdd51ee9\n"},{"id":"226052","messageId":"20130827194828.11172.45373.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":"20130827194022.11172.56453.chriscool@tuxfamily.org","subject":"[PATCH v2 3/5] t6050-replace: test that objects are of the same type","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-27T19:48:25Z","receivedAt":"2013-08-27T19:48:25Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t6050-replace.sh | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex decdc33..5c352c4 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -263,4 +263,17 @@ test_expect_success 'not just commits' '\n \ttest_cmp file.replaced file\n '\n \n+test_expect_success 'replaced and replacement objects must be of the same type' '\n+\ttest_must_fail git replace mytag $HASH1 2>err &&\n+\tgrep \"mytag. points to a replaced object of type .tag\" err &&\n+\tgrep \"$HASH1. points to a replacement object of type .commit\" err &&\n+\ttest_must_fail git replace HEAD^{tree} HEAD~1 2>err &&\n+\tgrep \"HEAD^{tree}. points to a replaced object of type .tree\" err &&\n+\tgrep \"HEAD~1. points to a replacement object of type .commit\" err &&\n+\tBLOB=$(git rev-parse :file) &&\n+\ttest_must_fail git replace HEAD^ $BLOB 2>err &&\n+\tgrep \"HEAD^. points to a replaced object of type .commit\" err &&\n+\tgrep \"$BLOB. points to a replacement object of type .blob\" err\n+'\n+\n test_done\n-- \n1.8.4.rc1.26.gdd51ee9\n"},{"id":"226051","messageId":"20130827194828.11172.6562.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":"20130827194022.11172.56453.chriscool@tuxfamily.org","subject":"[PATCH v2 4/5] t6050-replace: add test to clean up all the replace refs","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-27T19:48:26Z","receivedAt":"2013-08-27T19:48:26Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t6050-replace.sh | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex 5c352c4..05be228 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -276,4 +276,10 @@ test_expect_success 'replaced and replacement objects must be of the same type'\n \tgrep \"$BLOB. points to a replacement object of type .blob\" err\n '\n \n+test_expect_success 'replace ref cleanup' '\n+\ttest -n \"$(git replace)\" &&\n+\tgit replace -d $(git replace) &&\n+\ttest -z \"$(git replace)\"\n+'\n+\n test_done\n-- \n1.8.4.rc1.26.gdd51ee9\n"},{"id":"226054","messageId":"20130827194828.11172.95712.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":"20130827194022.11172.56453.chriscool@tuxfamily.org","subject":"[PATCH v2 5/5] Documentation/replace: add Creating Replacement Objects section","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-27T19:48:27Z","receivedAt":"2013-08-27T19:48:27Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"There were no hints in the documentation about how to create\nreplacement objects.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-replace.txt | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt\nindex aa66d27..736b48c 100644\n--- a/Documentation/git-replace.txt\n+++ b/Documentation/git-replace.txt\n@@ -64,6 +64,19 @@ OPTIONS\n \tTyping \"git replace\" without arguments, also lists all replace\n \trefs.\n \n+CREATING REPLACEMENT OBJECTS\n+----------------------------\n+\n+linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and\n+linkgit:git-rebase[1], among other git commands, can be used to create\n+replacement objects from existing objects.\n+\n+If you want to replace many blobs, trees or commits that are part of a\n+string of commits, you may just want to create a replacement string of\n+commits and then only replace the commit at the tip of the target\n+string of commits with the commit at the tip of the replacement string\n+of commits.\n+\n BUGS\n ----\n Comparing blobs or trees that have been replaced with those that\n@@ -76,6 +89,9 @@ pending objects.\n \n SEE ALSO\n --------\n+linkgit:git-hash-object[1]\n+linkgit:git-filter-branch[1]\n+linkgit:git-rebase[1]\n linkgit:git-tag[1]\n linkgit:git-branch[1]\n linkgit:git[1]\n-- \n1.8.4.rc1.26.gdd51ee9\n"},{"id":"226060","messageId":"xmqqk3j6c1x0.fsf@gitster.dls.corp.google.com","threadId":"34785","inReplyTo":"20130827194828.11172.73829.chriscool@tuxfamily.org","subject":"Re: [PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-27T20:30:03Z","receivedAt":"2013-08-27T20:30:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> Users replacing an object with one of a different type were not\n> prevented to do so, even if it was obvious, and stated in the doc,\n> that bad things would result from doing that.\n>\n> To avoid mistakes, it is better to just forbid that though.\n>\n> There is no case where one object can be replaced with one of a\n> different type while keeping the history valid, because:\n>\n> * Annotated tags contain the type of the tagged object.\n\nIf you replace the tagged object and the tag at the same time,\nwouldn't that make the resulting history valid again?\n\nGranted, there may not be a strong reason to reuse the object name\nof the tagged object in such a case, but this \"there may not be\" is\nmerely \"I do not think of offhand\", so I am not sure what workflow\nof other people we are breaking with this change.  A light-weight\ntag may already point at the tagged object (in other words, the\nobject name of the tagged object is known to the outside world) and\nthat could be a reason why you would need to reuse the object name\nof that object while changing its type.\n\nI dunno.\n"},{"id":"226080","messageId":"878uzmclva.fsf@linux-k42r.v.cablecom.net","threadId":"34785","inReplyTo":"xmqqk3j6c1x0.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2013-08-28T07:31:21Z","receivedAt":"2013-08-28T07:31:21Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Christian Couder <chriscool@tuxfamily.org> writes:\n>\n>> Users replacing an object with one of a different type were not\n>> prevented to do so, even if it was obvious, and stated in the doc,\n>> that bad things would result from doing that.\n>>\n>> To avoid mistakes, it is better to just forbid that though.\n>>\n>> There is no case where one object can be replaced with one of a\n>> different type while keeping the history valid, because:\n>>\n>> * Annotated tags contain the type of the tagged object.\n>\n> If you replace the tagged object and the tag at the same time,\n> wouldn't that make the resulting history valid again?\n>\n> Granted, there may not be a strong reason to reuse the object name\n> of the tagged object in such a case, but this \"there may not be\" is\n> merely \"I do not think of offhand\", so I am not sure what workflow\n> of other people we are breaking with this change.  A light-weight\n> tag may already point at the tagged object (in other words, the\n> object name of the tagged object is known to the outside world) and\n> that could be a reason why you would need to reuse the object name\n> of that object while changing its type.\n>\n> I dunno.\n\nHrm, you're right, that's a flaw in my logic.  You could do the same in\nall other cases too, e.g. replace a tree so that an entry is of a\ndifferent type and at the same time change the type of the object\nitself.  You however have to carefully go through all objects that refer\nto the one that was replaced, and fix the type in all of them.\n\nIt still seems an extremely unsafe thing to do with trees: especially\nfor small trees there is a small probability that you will generate the\nsame tree again in the future (by having the same blobs in the directory\nagain) and record it as a subtree or the 'tree' field of a commit.  The\nhistory would then again be invalid.\n\nShould we add a --force flag of some sort to allow the user to do this,\nwhile keeping the normal safety checks?\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"226104","messageId":"xmqqa9k1a9wq.fsf@gitster.dls.corp.google.com","threadId":"34785","inReplyTo":"878uzmclva.fsf@linux-k42r.v.cablecom.net","subject":"Re: [PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-28T19:32:37Z","receivedAt":"2013-08-28T19:32:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@inf.ethz.ch> writes:\n\n> Hrm, you're right, that's a flaw in my logic.  You could do the same in\n> all other cases too, e.g. replace a tree so that an entry is of a\n> different type and at the same time change the type of the object\n> itself.  You however have to carefully go through all objects that refer\n> to the one that was replaced, and fix the type in all of them.\n>\n> It still seems an extremely unsafe thing to do with trees...\n>  ...\n> Should we add a --force flag of some sort to allow the user to do this,\n> while keeping the normal safety checks?\n\nAs long as we do not forbid such an unusual replacement on the\nreading side, we won't break people who are more inventive than we\nare (I am not convinced that we know people's workflow well enough\nto definitively say that no sane workflow, which benefits from being\nable to replace an object with another from a different type,\nexists).\n\nPreventing \"git replace\" wrapper from creating such a replacement by\ndefault will make it harder to do and may reduce mistakes, without\nbreaking them too much, I think.\n"},{"id":"226136","messageId":"20130829.082936.1893875995125817253.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":"xmqqa9k1a9wq.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-29T06:29:36Z","receivedAt":"2013-08-29T06:29:36Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n>\n> Thomas Rast <trast@inf.ethz.ch> writes:\n> \n>> Hrm, you're right, that's a flaw in my logic.  You could do the same in\n>> all other cases too, e.g. replace a tree so that an entry is of a\n>> different type and at the same time change the type of the object\n>> itself.  You however have to carefully go through all objects that refer\n>> to the one that was replaced, and fix the type in all of them.\n>>\n>> It still seems an extremely unsafe thing to do with trees...\n>>  ...\n>> Should we add a --force flag of some sort to allow the user to do this,\n>> while keeping the normal safety checks?\n> \n> As long as we do not forbid such an unusual replacement on the\n> reading side, we won't break people who are more inventive than we\n> are (I am not convinced that we know people's workflow well enough\n> to definitively say that no sane workflow, which benefits from being\n> able to replace an object with another from a different type,\n> exists).\n> \n> Preventing \"git replace\" wrapper from creating such a replacement by\n> default will make it harder to do and may reduce mistakes, without\n> breaking them too much, I think.\n\nI agree. It is always possible to create replacement refs using \"git\nupdate-ref\" if one really wants to.\n\nWhat about using the following in the commit message or in the\ndocumentation:\n\n------------------------------------------\n\nDISCUSSION\n\nIf one object is replaced with one of a different type, the only way\nto keep the history valid is to also replace all the other objects\nthat point to the replaced object. That's because:\n\n* Annotated tags contain the type of the tagged object.\n\n* The tree/parent lines in commits must be a tree and commits, resp.\n\n* The object types referred to by trees are specified in the 'mode'\n  field:\n    100644 and 100755    blob\n    160000               commit\n    040000               tree\n  (these are the only valid modes)\n\n* Blobs don't point at anything.\n\nBut if all the objects that point to an object, called O, are to be\nreplaced, then in most cases object O probably doesn't need to be\nreplaced. It's probably sufficient to create the new object, called\nO2, that would replace object O and to replace all the objects\npointing to object O with objects pointing to O2.\n\nThe only case where someone might really want to replace object 0,\nwith an object O2 of a different type, and all the objects pointing to\nit, is if it's really important, perhaps for external reasons, to have\nobject O's SHA1 point to O2.\n\nAnd anyway, if one really wants to do that, it can still be done using\n\"git update-ref\".\n\n------------------------------------------\n\nThanks,\nChristian.\n"},{"id":"226183","messageId":"xmqqli3k7abw.fsf@gitster.dls.corp.google.com","threadId":"34785","inReplyTo":"20130829.082936.1893875995125817253.chriscool@tuxfamily.org","subject":"Re: [PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-29T16:04:03Z","receivedAt":"2013-08-29T16:04:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> But if all the objects that point to an object, called O, are to be\n> replaced, then in most cases object O probably doesn't need to be\n> replaced. It's probably sufficient to create the new object, called\n> O2, that would replace object O and to replace all the objects\n> pointing to object O with objects pointing to O2.\n\nHmmmm.\n\nWhat the above says, with \"probably\" and \"most cases\", can easily\ninferred by anybody remotely intelligent, and the only reason to\nhave something like the above paragraph would be if it assures that\nthe statement holds without these qualifications to weaken it, which\nit doesn't.  I am not sure this paragraph adds much value.\n\n> The only case where someone might really want to replace object 0,\n> with an object O2 of a different type, and all the objects pointing to\n> it, is if it's really important, perhaps for external reasons, to have\n> object O's SHA1 point to O2.\n\nThe same comment applies here.\n\n> And anyway, if one really wants to do that, it can still be done using\n> \"git update-ref\".\n\nAnd I really do not think this sentence is right---you can justify\nwith the same sentence to remove \"git replace\" wrapper.\n\nThe earlier suggestion to bypass the new hand-holding with \"--force\"\nis more sensible, I think.\n"},{"id":"226295","messageId":"20130830.074124.1031903859178992049.chriscool@tuxfamily.org","threadId":"34785","inReplyTo":"xmqqli3k7abw.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2013-08-30T05:41:24Z","receivedAt":"2013-08-30T05:41:24Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n>\n> Christian Couder <chriscool@tuxfamily.org> writes:\n> \n>> But if all the objects that point to an object, called O, are to be\n>> replaced, then in most cases object O probably doesn't need to be\n>> replaced. It's probably sufficient to create the new object, called\n>> O2, that would replace object O and to replace all the objects\n>> pointing to object O with objects pointing to O2.\n> \n> Hmmmm.\n> \n> What the above says, with \"probably\" and \"most cases\", can easily\n> inferred by anybody remotely intelligent, and the only reason to\n> have something like the above paragraph would be if it assures that\n> the statement holds without these qualifications to weaken it, which\n> it doesn't.  I am not sure this paragraph adds much value.\n> \n>> The only case where someone might really want to replace object 0,\n>> with an object O2 of a different type, and all the objects pointing to\n>> it, is if it's really important, perhaps for external reasons, to have\n>> object O's SHA1 point to O2.\n> \n> The same comment applies here.\n> \n>> And anyway, if one really wants to do that, it can still be done using\n>> \"git update-ref\".\n> \n> And I really do not think this sentence is right---you can justify\n> with the same sentence to remove \"git replace\" wrapper.\n\nOk, so the commit message (excluding the Acked-by and Signed-off-by)\nwill be only:\n\n------------------------------------------\n\nUsers replacing an object with one of a different type were not\nprevented to do so, even if it was obvious, and stated in the doc,\nthat bad things would result from doing that.\n\nTo avoid mistakes, it is better to just forbid that though.\n\nIf one object is replaced with one of a different type, the only way\nto keep the history valid is to also replace all the other objects\nthat point to the replaced object. That's because:\n\n* Annotated tags contain the type of the tagged object.\n\n* The tree/parent lines in commits must be a tree and commits, resp.\n\n* The object types referred to by trees are specified in the 'mode'\n  field:\n    100644 and 100755    blob\n    160000               commit\n    040000               tree\n  (these are the only valid modes)\n\n* Blobs don't point at anything.\n\nThe doc will be updated in a later patch.\n\n------------------------------------------\n\n> The earlier suggestion to bypass the new hand-holding with \"--force\"\n> is more sensible, I think.\n\nThere is already a --force option, but I can add a --force-type in a\nanother patch.\n\nThanks,\nChristian.\n"},{"id":"226343","messageId":"xmqqa9jz15p4.fsf@gitster.dls.corp.google.com","threadId":"34785","inReplyTo":"20130830.074124.1031903859178992049.chriscool@tuxfamily.org","subject":"Re: [PATCH v2 1/5] replace: forbid replacing an object with one of a different type","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-30T16:52:55Z","receivedAt":"2013-08-30T16:52:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> There is already a --force option, but I can add a --force-type in a\n> another patch.\n\nOh, that was not what I meant.  As long as existing --force override\nthis check, that should be sufficient and more preferrable than yet\nanother kind of \"force\".\n\nThanks.\n"}]}