{"thread":{"id":"32104","subject":"git-gui / Warning: \"No newline at end of file”","startedAt":"2012-11-13T20:26:53Z","lastAt":"2013-05-10T19:09:53Z","messageCount":5,"participants":["Tobias Preuss","Pat Thoyts","Heiko Voigt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"203142","messageId":"CADEaiE-J4nEwyK4WSiH=zzaH6cb85mw15O3wxrWrTXJtZfJixQ@mail.gmail.com","threadId":"32104","inReplyTo":null,"subject":"git-gui / Warning: \"No newline at end of file”","fromName":"Tobias Preuss","fromEmail":"tobias.preuss@googlemail.com","sentAt":"2012-11-13T20:26:53Z","receivedAt":"2012-11-13T20:26:53Z","isPatch":false,"sender":{"key":"tobias.preuss@googlemail.com","avatar":"https://gravatar.com/avatar/aa7f7cede53018ff874dfb61fa4de920fff33234f1dd0570a9bed1630c3dce60?d=mp&s=160"},"body":"Hello.\nI noticed a problem when working with git-gui which might be a bug.\nThe issue only affects you when you are visually trying to stage\nchanges line by line. Here are the steps to reproduce the problem:\n\n1. Initialize a new repository.\n2. Create a file with three lines of content each with the word\n\"Hello\". Do not put a new line at the end of the file.\n3. Add and commit the file.\n4. Edit the same file putting words inbetween the three lines.\n5. Open git-gui and try to stage the changes line by line.\n\nThe editor will append the warning \"No newline at end of file” to the\nend of the diff. When you are trying to stage a line an error occurs.\nThe problem is also illustrated in a question on Stackoverflow [1].\n\nPlease let me know if you need more information or if I should send\nthis problem to some other mailing list.\nThank you, Tobias\n\n____________\n[1] http://stackoverflow.com/questions/13223868/how-to-stage-line-by-line-in-git-gui-although-no-newline-at-end-of-file-warnin\n"},{"id":"205922","messageId":"CADEaiE8GKfSQ5u+0bb8qtBe-3OTYJThGb-UFLU_pM-T9ZqvkiA@mail.gmail.com","threadId":"32104","inReplyTo":"CADEaiE-J4nEwyK4WSiH=zzaH6cb85mw15O3wxrWrTXJtZfJixQ@mail.gmail.com","subject":"Fwd: git-gui / Warning: \"No newline at end of file”","fromName":"Tobias Preuss","fromEmail":"tobias.preuss@googlemail.com","sentAt":"2013-01-03T12:26:59Z","receivedAt":"2013-01-03T12:26:59Z","isPatch":false,"sender":{"key":"tobias.preuss@googlemail.com","avatar":"https://gravatar.com/avatar/aa7f7cede53018ff874dfb61fa4de920fff33234f1dd0570a9bed1630c3dce60?d=mp&s=160"},"body":"Hello. I never got a response. Did my email pass the distribution\nlist? Best, Tobias\n\n\n---------- Forwarded message ----------\nFrom: Tobias Preuss <tobias.preuss@googlemail.com>\nDate: Tue, Nov 13, 2012 at 9:26 PM\nSubject: git-gui / Warning: \"No newline at end of file”\nTo: git <git@vger.kernel.org>\n\n\nHello.\nI noticed a problem when working with git-gui which might be a bug.\nThe issue only affects you when you are visually trying to stage\nchanges line by line. Here are the steps to reproduce the problem:\n\n1. Initialize a new repository.\n2. Create a file with three lines of content each with the word\n\"Hello\". Do not put a new line at the end of the file.\n3. Add and commit the file.\n4. Edit the same file putting words inbetween the three lines.\n5. Open git-gui and try to stage the changes line by line.\n\nThe editor will append the warning \"No newline at end of file” to the\nend of the diff. When you are trying to stage a line an error occurs.\nThe problem is also illustrated in a question on Stackoverflow [1].\n\nPlease let me know if you need more information or if I should send\nthis problem to some other mailing list.\nThank you, Tobias\n\n____________\n[1] http://stackoverflow.com/questions/13223868/how-to-stage-line-by-line-in-git-gui-although-no-newline-at-end-of-file-warnin\n"},{"id":"206382","messageId":"87vcb6bee5.fsf@fox.patthoyts.tk","threadId":"32104","inReplyTo":"7vzk0qw8ts.fsf@alter.siamese.dyndns.org","subject":"Re: Fwd: git-gui / Warning: \"No newline at end of file”","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2013-01-09T14:49:06Z","receivedAt":"2013-01-09T14:49:06Z","isPatch":false,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>Tobias Preuss <tobias.preuss@googlemail.com> writes:\n>\n>> Hello. I never got a response. Did my email pass the distribution\n>> list? Best, Tobias\n>\n>Pat?\n>\n\nI did have a brief look at this but I don't have a solution at the\nmoment. The \"\\ No newline at end of file\" is emitted by git at we don't\nappear to handle it well in the lib/diff.tcl apply_range_or_line\nfunction.\n\n>> ---------- Forwarded message ----------\n>> From: Tobias Preuss <tobias.preuss@googlemail.com>\n>> Date: Tue, Nov 13, 2012 at 9:26 PM\n>> Subject: git-gui / Warning: \"No newline at end of file”\n>> To: git <git@vger.kernel.org>\n>>\n>>\n>> Hello.\n>> I noticed a problem when working with git-gui which might be a bug.\n>> The issue only affects you when you are visually trying to stage\n>> changes line by line. Here are the steps to reproduce the problem:\n>>\n>> 1. Initialize a new repository.\n>> 2. Create a file with three lines of content each with the word\n>> \"Hello\". Do not put a new line at the end of the file.\n>> 3. Add and commit the file.\n>> 4. Edit the same file putting words inbetween the three lines.\n>> 5. Open git-gui and try to stage the changes line by line.\n>>\n>> The editor will append the warning \"No newline at end of file” to the\n>> end of the diff. When you are trying to stage a line an error occurs.\n>> The problem is also illustrated in a question on Stackoverflow [1].\n>>\n>> Please let me know if you need more information or if I should send\n>> this problem to some other mailing list.\n>> Thank you, Tobias\n>>\n>> ____________\n>> [1] http://stackoverflow.com/questions/13223868/how-to-stage-line-by-line-in-git-gui-although-no-newline-at-end-of-file-warnin\n>\n\n-- \nPat Thoyts                            http://www.patthoyts.tk/\nPGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n"},{"id":"216781","messageId":"20130509163002.GA3630@book-mint","threadId":"32104","inReplyTo":"87vcb6bee5.fsf@fox.patthoyts.tk","subject":"[PATCH] git-gui: allow \"\\ No newline at end of file\" for linewise staging","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2013-05-09T16:30:03Z","receivedAt":"2013-05-09T16:30:03Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Counting of lines did not skip this line when generating the hunk\nheader.\n\nSigned-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n---\nHere is an attempt at fixing the no newline issue. I would appreciate\nanother pair of eyes though.\n\n git-gui/lib/diff.tcl | 11 +++++++++--\n 1 file changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex ec44055..30d9a79 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -764,8 +764,15 @@ proc apply_range_or_line {x y} {\n \t\t\t\t# context line\n \t\t\t\tset ln [$ui_diff get $i_l $next_l]\n \t\t\t\tset patch \"$patch$pre_context$ln\"\n-\t\t\t\tset n [expr $n+1]\n-\t\t\t\tset m [expr $m+1]\n+\t\t\t\t# Skip the \"\\ No newline at end of\n+\t\t\t\t# file\". Depending on the locale setting\n+\t\t\t\t# we don't know what this line looks\n+\t\t\t\t# like exactly. The only thing we do\n+\t\t\t\t# know is that it starts with \"\\ \"\n+\t\t\t\tif {![string match {\\\\ *} $ln]} {\n+\t\t\t\t\tset n [expr $n+1]\n+\t\t\t\t\tset m [expr $m+1]\n+\t\t\t\t}\n \t\t\t\tset pre_context {}\n \t\t\t} elseif {$c1 eq $to_context} {\n \t\t\t\t# turn change line into context line\n-- \n1.8.3.rc1.40.gba374ae\n"},{"id":"216928","messageId":"CADEaiE_ddTLO0kYL5siN4rmycibuzHA3R1dz9mKyueYd0y_atw@mail.gmail.com","threadId":"32104","inReplyTo":"20130509163002.GA3630@book-mint","subject":"Re: [PATCH] git-gui: allow \"\\ No newline at end of file\" for linewise staging","fromName":"Tobias Preuss","fromEmail":"tobias.preuss@googlemail.com","sentAt":"2013-05-10T19:09:53Z","receivedAt":"2013-05-10T19:09:53Z","isPatch":true,"sender":{"key":"tobias.preuss@googlemail.com","avatar":"https://gravatar.com/avatar/aa7f7cede53018ff874dfb61fa4de920fff33234f1dd0570a9bed1630c3dce60?d=mp&s=160"},"body":"I tested the patch as I am the same person that bothered about the\nbehavior a while ago. Please merge.\n- Sorry for sending an HTML formatted mail before.\n\nOn Thu, May 9, 2013 at 6:30 PM, Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> Counting of lines did not skip this line when generating the hunk\n> header.\n>\n> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n> ---\n> Here is an attempt at fixing the no newline issue. I would appreciate\n> another pair of eyes though.\n>\n>  git-gui/lib/diff.tcl | 11 +++++++++--\n>  1 file changed, 9 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\n> index ec44055..30d9a79 100644\n> --- a/git-gui/lib/diff.tcl\n> +++ b/git-gui/lib/diff.tcl\n> @@ -764,8 +764,15 @@ proc apply_range_or_line {x y} {\n>                                 # context line\n>                                 set ln [$ui_diff get $i_l $next_l]\n>                                 set patch \"$patch$pre_context$ln\"\n> -                               set n [expr $n+1]\n> -                               set m [expr $m+1]\n> +                               # Skip the \"\\ No newline at end of\n> +                               # file\". Depending on the locale setting\n> +                               # we don't know what this line looks\n> +                               # like exactly. The only thing we do\n> +                               # know is that it starts with \"\\ \"\n> +                               if {![string match {\\\\ *} $ln]} {\n> +                                       set n [expr $n+1]\n> +                                       set m [expr $m+1]\n> +                               }\n>                                 set pre_context {}\n>                         } elseif {$c1 eq $to_context} {\n>                                 # turn change line into context line\n> --\n> 1.8.3.rc1.40.gba374ae\n>\n"}]}