{"thread":{"id":"18015","subject":"Bug in Git-Gui - Creates corrupt patch","startedAt":"2009-02-25T15:03:22Z","lastAt":"2009-03-02T14:39:28Z","messageCount":7,"participants":["4jxdq6fqee2h@dyweni.com","Johannes Sixt","Grzegorz Kossakowski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"106225","messageId":"20090225090322.301cdb77@family.dyweni.com","threadId":"18015","inReplyTo":null,"subject":"Bug in Git-Gui - Creates corrupt patch","fromName":"","fromEmail":"4jxdq6fqee2h@dyweni.com","sentAt":"2009-02-25T15:03:22Z","receivedAt":"2009-02-25T15:03:22Z","isPatch":false,"sender":{"key":"4jxdq6fqee2h@dyweni.com","avatar":null},"body":"Hi Shawn,\n\nI have stumbled upon a bug in Git-GUi and am providing reproduction\nsteps:\n\n\n\n1.  Commit this file into a new git repository:\n\n-----------------------------\n<?php\n\nclass myclass {\n\tpublic function funcAbc() {\n\t\techo \"line 1\";\n\t\techo \"line 2\";\n\t\techo \"line 3\";\n\t\techo \"line 4\";\n\t\techo \"line 5\";\n\t}\n\t\n\tpublic function funcBCD() {\n\t\techo \"line 1-1\";\n\t\techo \"line 2-1\";\n\t\techo \"line 3-1\";\n\t\techo \"line 4-1\";\n\t\techo \"line 5-1\";\n\t}\n}\n\n?>\n--------------\n\nHere is the base64 encoded version:\n\nPD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo\nbyAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu\nZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQoJCglwdWJsaWMgZnVuY3Rpb24gZnVuY0JDRCgpIHsK\nCQllY2hvICJsaW5lIDEtMSI7CgkJZWNobyAibGluZSAyLTEiOwoJCWVjaG8gImxpbmUgMy0xIjsK\nCQllY2hvICJsaW5lIDQtMSI7CgkJZWNobyAibGluZSA1LTEiOwoJfQp9Cgo/Pg==\n\n\n\n\n2.  Now delete the last function in the class.  Here's the resulting\nfile, it is not staged or commited yet.\n\n----------------------------\n<?php\n\nclass myclass {\n\tpublic function funcAbc() {\n\t\techo \"line 1\";\n\t\techo \"line 2\";\n\t\techo \"line 3\";\n\t\techo \"line 4\";\n\t\techo \"line 5\";\n\t}\n}\n\n?>\n----------------------------\n\n\nHere is the base64 encoded version:\n\nPD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo\nbyAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu\nZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQp9Cgo/Pg==\n\n\n\n\n3. Using git-gui, try to stage *only* the last line marked for removal\n(should be '-\t}').\n\nI get 'fatal: corrupt patch at line 22'.\n\n\n\n\n4. Now try the same task using git-add -p.   Start 'git-add -p'.  Enter\nedit mode (e).  Remove all the '-' lines except the last one (make\nthem ' ') so that only the last '-' will be removed. Save and exit.\n\nOn my system the patch is committed.\n\n\n\n\n\nI'm running git version 1.6.0.6, 32bit linux, Gentoo OS\n"},{"id":"106226","messageId":"20090225092650.6d2730ac@family.dyweni.com","threadId":"18015","inReplyTo":"20090225090322.301cdb77@family.dyweni.com","subject":"Re: Bug in Git-Gui - Creates corrupt patch","fromName":"","fromEmail":"4jxdq6fqee2h@dyweni.com","sentAt":"2009-02-25T15:26:50Z","receivedAt":"2009-02-25T15:26:50Z","isPatch":false,"sender":{"key":"4jxdq6fqee2h@dyweni.com","avatar":null},"body":"Shawn,\n\nI've added these lines to '/usr/share/git-gui/lib/diff.tcl' in the\n'catch' block of apply_line():\n----------------------------------------------\nputs -nonewline stdout $p\nputs -nonewline stdout $current_diff_header\nputs -nonewline stdout $patch\n----------------------------------------------\n\n\nThis produces the following patch that gets sent to git-apply:\n\n---------------------------------------------\nfile7diff --git a/file b/file\n--- a/file\n+++ b/file\n@@ -6,17 +6,16 @@\n                echo \"line 2\";\n                echo \"line 3\";\n                echo \"line 4\";\n                echo \"line 5\";\n        }\n        \n        public function funcBCD() {\n                echo \"line 1-1\";\n                echo \"line 2-1\";\n                echo \"line 3-1\";\n                echo \"line 4-1\";\n                echo \"line 5-1\";\n-       }\n }\n \n ?>\n\\ No newline at end of file\n---------------------------------------------\n\n\nHere's the base64 encoded version:\n\nZmlsZTdkaWZmIC0tZ2l0IGEvZmlsZSBiL2ZpbGUKLS0tIGEvZmlsZQorKysgYi9maWxlCkBAIC02\nLDE3ICs2LDE2IEBACiAJCWVjaG8gImxpbmUgMiI7CiAJCWVjaG8gImxpbmUgMyI7CiAJCWVjaG8g\nImxpbmUgNCI7CiAJCWVjaG8gImxpbmUgNSI7CiAJfQogCQogCXB1YmxpYyBmdW5jdGlvbiBmdW5j\nQkNEKCkgewogCQllY2hvICJsaW5lIDEtMSI7CiAJCWVjaG8gImxpbmUgMi0xIjsKIAkJZWNobyAi\nbGluZSAzLTEiOwogCQllY2hvICJsaW5lIDQtMSI7CiAJCWVjaG8gImxpbmUgNS0xIjsKLQl9CiB9\nCiAKID8+ClwgTm8gbmV3bGluZSBhdCBlbmQgb2YgZmlsZQo=\n\n\n\n\n> From: <4jxDQ6FQee2H@dyweni.com>\n> To: spearce@spearce.org\n> Cc: git@vger.kernel.org\n> Subject: Bug in Git-Gui - Creates corrupt patch\n> Date: Wed, 25 Feb 2009 09:03:22 -0600\n> Reply-To: 4jxDQ6FQee2H@dyweni.com\n> Sender: git-owner@vger.kernel.org\n> X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.11; i686-pc-linux-gnu)\n> \n> Hi Shawn,\n> \n> I have stumbled upon a bug in Git-GUi and am providing reproduction\n> steps:\n> \n> \n> \n> 1.  Commit this file into a new git repository:\n> \n> -----------------------------\n> <?php\n> \n> class myclass {\n> \tpublic function funcAbc() {\n> \t\techo \"line 1\";\n> \t\techo \"line 2\";\n> \t\techo \"line 3\";\n> \t\techo \"line 4\";\n> \t\techo \"line 5\";\n> \t}\n> \t\n> \tpublic function funcBCD() {\n> \t\techo \"line 1-1\";\n> \t\techo \"line 2-1\";\n> \t\techo \"line 3-1\";\n> \t\techo \"line 4-1\";\n> \t\techo \"line 5-1\";\n> \t}\n> }\n> \n> ?>  \n> --------------\n> \n> Here is the base64 encoded version:\n> \n> PD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo\n> byAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu\n> ZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQoJCglwdWJsaWMgZnVuY3Rpb24gZnVuY0JDRCgpIHsK\n> CQllY2hvICJsaW5lIDEtMSI7CgkJZWNobyAibGluZSAyLTEiOwoJCWVjaG8gImxpbmUgMy0xIjsK\n> CQllY2hvICJsaW5lIDQtMSI7CgkJZWNobyAibGluZSA1LTEiOwoJfQp9Cgo/Pg==\n> \n> \n> \n> \n> 2.  Now delete the last function in the class.  Here's the resulting\n> file, it is not staged or commited yet.\n> \n> ----------------------------\n> <?php\n> \n> class myclass {\n> \tpublic function funcAbc() {\n> \t\techo \"line 1\";\n> \t\techo \"line 2\";\n> \t\techo \"line 3\";\n> \t\techo \"line 4\";\n> \t\techo \"line 5\";\n> \t}\n> }\n> \n> ?>  \n> ----------------------------\n> \n> \n> Here is the base64 encoded version:\n> \n> PD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo\n> byAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu\n> ZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQp9Cgo/Pg==\n> \n> \n> \n> \n> 3. Using git-gui, try to stage *only* the last line marked for removal\n> (should be '-\t}').\n> \n> I get 'fatal: corrupt patch at line 22'.\n> \n> \n> \n> \n> 4. Now try the same task using git-add -p.   Start 'git-add -p'.\n> Enter edit mode (e).  Remove all the '-' lines except the last one\n> (make them ' ') so that only the last '-' will be removed. Save and\n> exit.\n> \n> On my system the patch is committed.\n> \n> \n> \n> \n> \n> I'm running git version 1.6.0.6, 32bit linux, Gentoo OS\n> \n> \n> \n> \n> \n> \n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"106227","messageId":"49A567C9.5050203@viscovery.net","threadId":"18015","inReplyTo":"20090225090322.301cdb77@family.dyweni.com","subject":"Re: Bug in Git-Gui - Creates corrupt patch","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-02-25T15:46:17Z","receivedAt":"2009-02-25T15:46:17Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"4jxDQ6FQee2H@dyweni.com schrieb:\n> 3. Using git-gui, try to stage *only* the last line marked for removal\n> (should be '-\t}').\n> \n> I get 'fatal: corrupt patch at line 22'.\n\n\"Stage/Unstage line\" does not work for files that have\n\n\\ No newline at end of file\n\n-- Hannes\n"},{"id":"106228","messageId":"20090225101037.104b48a1@family.dyweni.com","threadId":"18015","inReplyTo":"49A567C9.5050203@viscovery.net","subject":"Re: Bug in Git-Gui - Creates corrupt patch","fromName":"","fromEmail":"4jxdq6fqee2h@dyweni.com","sentAt":"2009-02-25T16:10:37Z","receivedAt":"2009-02-25T16:10:37Z","isPatch":false,"sender":{"key":"4jxdq6fqee2h@dyweni.com","avatar":null},"body":"Hannes / List,\n\nThank you for the advise on \"\\ No newline at end of file\".\n\nI have almost 4,000 files that are formatted with \"\\ No newline at end\nof file\".  Does anyone know of an easy way to re-format my files so\nthat they have a newline at the end?\n\nThe files in question are PHP files that are dynamically included, so I\nwant to prevent arbitrary spaces from showing up in the rendered pages.\n\nI'm running Linux.  A bash or perl script would be preferable, but\nanything will suffice.\n\nThanks!\n\n\n> Johannes Sixt <j.sixt@viscovery.net> wrote:\n>\n> 4jxDQ6FQee2H@dyweni.com schrieb:\n> > 3. Using git-gui, try to stage *only* the last line marked for\n> > removal (should be '-\t}').\n> > \n> > I get 'fatal: corrupt patch at line 22'.  \n> \n> \"Stage/Unstage line\" does not work for files that have\n> \n> \\ No newline at end of file\n> \n> -- Hannes\n> \n"},{"id":"106230","messageId":"20090225102453.38d993ce@family.dyweni.com","threadId":"18015","inReplyTo":"20090225101037.104b48a1@family.dyweni.com","subject":"Re: Bug in Git-Gui - Creates corrupt patch","fromName":"","fromEmail":"4jxdq6fqee2h@dyweni.com","sentAt":"2009-02-25T16:24:53Z","receivedAt":"2009-02-25T16:24:53Z","isPatch":false,"sender":{"key":"4jxdq6fqee2h@dyweni.com","avatar":null},"body":"In case anyone else is facing this same situation, a simple script like\nthis did the trick for me:\n\n------------------------------------------------\n#!/bin/bash\n\nfind ./ -type f | grep -v .git | while read filename\ndo\n\tlast=$(\n\t\ttail -c 1 \"$filename\" | \n\t\tod -x | \n\t\thead -n 1 | \n\t\tawk '{ print $2 }'\n\t)\n\t\n\tif [ \"x$last\" != \"x000a\" ]\n\tthen\n\t\techo >> \"$filename\"\n\tfi\ndone\n------------------------------------------------\n\n\n> <4jxDQ6FQee2H@dyweni.com> wrote:\n> \n> Hannes / List,\n> \n> Thank you for the advise on \"\\ No newline at end of file\".\n> \n> I have almost 4,000 files that are formatted with \"\\ No newline at end\n> of file\".  Does anyone know of an easy way to re-format my files so\n> that they have a newline at the end?\n> \n> The files in question are PHP files that are dynamically included, so\n> I want to prevent arbitrary spaces from showing up in the rendered\n> pages.\n> \n> I'm running Linux.  A bash or perl script would be preferable, but\n> anything will suffice.\n> \n> Thanks!\n> \n> \n> > Johannes Sixt <j.sixt@viscovery.net> wrote:\n> >\n> > 4jxDQ6FQee2H@dyweni.com schrieb:  \n> > > 3. Using git-gui, try to stage *only* the last line marked for\n> > > removal (should be '-\t}').\n> > > \n> > > I get 'fatal: corrupt patch at line 22'.    \n> > \n> > \"Stage/Unstage line\" does not work for files that have\n> > \n> > \\ No newline at end of file\n> > \n> > -- Hannes\n"},{"id":"106705","messageId":"49ABEE6C.3000500@tuffmail.com","threadId":"18015","inReplyTo":"49A567C9.5050203@viscovery.net","subject":"Re: Bug in Git-Gui - Creates corrupt patch","fromName":"Grzegorz Kossakowski","fromEmail":"grek@tuffmail.com","sentAt":"2009-03-02T14:34:20Z","receivedAt":"2009-03-02T14:34:20Z","isPatch":false,"sender":{"key":"grek@tuffmail.com","avatar":"https://gravatar.com/avatar/98a80b7992e9f598c7b24addc73338dbacf94a14e4a14f3fa50c3f00dbee7dd3?d=mp&s=160"},"body":"Johannes Sixt pisze:\n> 4jxDQ6FQee2H@dyweni.com schrieb:\n>> 3. Using git-gui, try to stage *only* the last line marked for removal\n>> (should be '-\t}').\n>>\n>> I get 'fatal: corrupt patch at line 22'.\n> \n> \"Stage/Unstage line\" does not work for files that have\n> \n> \\ No newline at end of file\n\nI've just stumpled across this problem. Does above imply that reported problem is not considered as a bug?\n\nIf so I believe that git gui should enforce new lines at the end of a file or at least provide more meaningful error msg.\n\n-- \nBest regards,\nGrzegorz Kossakowski\n"},{"id":"106706","messageId":"49ABEFA0.9090808@viscovery.net","threadId":"18015","inReplyTo":"49ABEE6C.3000500@tuffmail.com","subject":"Re: Bug in Git-Gui - Creates corrupt patch","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-03-02T14:39:28Z","receivedAt":"2009-03-02T14:39:28Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Grzegorz Kossakowski schrieb:\n> Johannes Sixt pisze:\n>> 4jxDQ6FQee2H@dyweni.com schrieb:\n>>> 3. Using git-gui, try to stage *only* the last line marked for removal\n>>> (should be '-\t}').\n>>>\n>>> I get 'fatal: corrupt patch at line 22'.\n>> \"Stage/Unstage line\" does not work for files that have\n>>\n>> \\ No newline at end of file\n> \n> I've just stumpled across this problem. Does above imply that reported problem is not considered as a bug?\n\nNo, it means that I was too lazy to implement it. I tried to do that after\nthis report came in, but gave up because it is not trivial and I have too\nlittle time to think it through. :-(\n\n-- Hannes\n"}]}