{"thread":{"id":"5030","subject":"[PATCH] cg-commit --review may permanently delete changes","startedAt":"2006-07-28T17:11:52Z","lastAt":"2006-09-24T15:50:48Z","messageCount":2,"participants":["Dennis Stosberg","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"24312","messageId":"20060728171152.G3a9ef049@leonov.stosberg.net","threadId":"5030","inReplyTo":null,"subject":"[PATCH] cg-commit --review may permanently delete changes","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-07-28T17:11:52Z","receivedAt":"2006-07-28T17:11:52Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"If the patch is changed in the editor in such a way that cg-patch\ncan not apply it, all changes made since the last commit are\nirrecoverably lost, which is _really_ bad.\n\nThis patch lets cg-commit reapply the old patch and keep the edited\npatch for manual fix-up.\n\nSigned-off-by: Dennis Stosberg <dennis@stosberg.net>\n---\n cg-commit |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/cg-commit b/cg-commit\nindex 0cec58f..9604ad7 100755\n--- a/cg-commit\n+++ b/cg-commit\n@@ -524,8 +524,11 @@ if [ \"$review\" ]; then\n \t\tfi\n \t\techo \"Applying the edited patch...\"\n \t\tif ! cg-patch < \"$PATCH2\"; then\n-\t\t\trm \"$PATCH\" \"$PATCH2\" \"$LOGMSG\"\n-\t\t\tdie \"unable to apply the edited patch\"\n+\t\t\techo \"The edited patch does not apply. Reapplying old patch.\"\n+\t\t\tcg-patch <\"$PATCH\" >/dev/null\n+\t\t\tedited_patch=\"$(mktemp -t edited-patch.XXXXXX)\"\n+\t\t\tmv \"$PATCH2\" \"$edited_patch\"\n+\t\t\tdie \"You can find the edited patch in \\\"$edited_patch\\\" for manual review.\"\n \t\tfi\n \tfi\n fi\n-- \n1.4.1\n"},{"id":"27555","messageId":"20060924155048.GR20017@pasky.or.cz","threadId":"5030","inReplyTo":"20060728171152.G3a9ef049@leonov.stosberg.net","subject":"Re: [PATCH] cg-commit --review may permanently delete changes","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-09-24T15:50:48Z","receivedAt":"2006-09-24T15:50:48Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Jul 28, 2006 at 07:11:52PM CEST, I got a letter\nwhere Dennis Stosberg <dennis@stosberg.net> said that...\n> If the patch is changed in the editor in such a way that cg-patch\n> can not apply it, all changes made since the last commit are\n> irrecoverably lost, which is _really_ bad.\n> \n> This patch lets cg-commit reapply the old patch and keep the edited\n> patch for manual fix-up.\n> \n> Signed-off-by: Dennis Stosberg <dennis@stosberg.net>\n\nHmm, good catch. Unfortunately, we can't safely patch the original patch\nover that either, since bits of the edited patch _might_ got applied.\n\nAs the first step, I've prevented Cogito from deleting any of the\ntemporary files and now it instead reports their name to the user and\nlets him fix up the situation.\n\nAs the second stage, we should restore the original state of the tree. I\nwill do it when I get to it, patches welcome. :-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\n#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj\n$/=unpack('H*',$_);$_=`echo 16dio\\U$k\"SK$/SM$n\\EsN0p[lN*1\nlK[d2%Sa2/d0$^Ixp\"|dc`;s/\\W//g;$_=pack('H*',/((..)*)$/)\n"}]}