git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git-gui / Warning: "No newline at end of file”
@ 2012-11-13 20:26 Tobias Preuss
  2013-01-03 12:26 ` Fwd: " Tobias Preuss
  0 siblings, 1 reply; 5+ messages in thread
From: Tobias Preuss @ 2012-11-13 20:26 UTC (permalink / raw)
  To: git

Hello.
I noticed a problem when working with git-gui which might be a bug.
The issue only affects you when you are visually trying to stage
changes line by line. Here are the steps to reproduce the problem:

1. Initialize a new repository.
2. Create a file with three lines of content each with the word
"Hello". Do not put a new line at the end of the file.
3. Add and commit the file.
4. Edit the same file putting words inbetween the three lines.
5. Open git-gui and try to stage the changes line by line.

The editor will append the warning "No newline at end of file” to the
end of the diff. When you are trying to stage a line an error occurs.
The problem is also illustrated in a question on Stackoverflow [1].

Please let me know if you need more information or if I should send
this problem to some other mailing list.
Thank you, Tobias

____________
[1] http://stackoverflow.com/questions/13223868/how-to-stage-line-by-line-in-git-gui-although-no-newline-at-end-of-file-warnin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fwd: git-gui / Warning: "No newline at end of file”
  2012-11-13 20:26 git-gui / Warning: "No newline at end of file” Tobias Preuss
@ 2013-01-03 12:26 ` Tobias Preuss
       [not found]   ` <7vzk0qw8ts.fsf@alter.siamese.dyndns.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Tobias Preuss @ 2013-01-03 12:26 UTC (permalink / raw)
  To: git

Hello. I never got a response. Did my email pass the distribution
list? Best, Tobias


---------- Forwarded message ----------
From: Tobias Preuss <tobias.preuss@googlemail.com>
Date: Tue, Nov 13, 2012 at 9:26 PM
Subject: git-gui / Warning: "No newline at end of file”
To: git <git@vger.kernel.org>


Hello.
I noticed a problem when working with git-gui which might be a bug.
The issue only affects you when you are visually trying to stage
changes line by line. Here are the steps to reproduce the problem:

1. Initialize a new repository.
2. Create a file with three lines of content each with the word
"Hello". Do not put a new line at the end of the file.
3. Add and commit the file.
4. Edit the same file putting words inbetween the three lines.
5. Open git-gui and try to stage the changes line by line.

The editor will append the warning "No newline at end of file” to the
end of the diff. When you are trying to stage a line an error occurs.
The problem is also illustrated in a question on Stackoverflow [1].

Please let me know if you need more information or if I should send
this problem to some other mailing list.
Thank you, Tobias

____________
[1] http://stackoverflow.com/questions/13223868/how-to-stage-line-by-line-in-git-gui-although-no-newline-at-end-of-file-warnin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: git-gui / Warning: "No newline at end of file”
       [not found]   ` <7vzk0qw8ts.fsf@alter.siamese.dyndns.org>
@ 2013-01-09 14:49     ` Pat Thoyts
  2013-05-09 16:30       ` [PATCH] git-gui: allow "\ No newline at end of file" for linewise staging Heiko Voigt
  0 siblings, 1 reply; 5+ messages in thread
From: Pat Thoyts @ 2013-01-09 14:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Tobias Preuss

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

>Tobias Preuss <tobias.preuss@googlemail.com> writes:
>
>> Hello. I never got a response. Did my email pass the distribution
>> list? Best, Tobias
>
>Pat?
>

I did have a brief look at this but I don't have a solution at the
moment. The "\ No newline at end of file" is emitted by git at we don't
appear to handle it well in the lib/diff.tcl apply_range_or_line
function.

>> ---------- Forwarded message ----------
>> From: Tobias Preuss <tobias.preuss@googlemail.com>
>> Date: Tue, Nov 13, 2012 at 9:26 PM
>> Subject: git-gui / Warning: "No newline at end of file”
>> To: git <git@vger.kernel.org>
>>
>>
>> Hello.
>> I noticed a problem when working with git-gui which might be a bug.
>> The issue only affects you when you are visually trying to stage
>> changes line by line. Here are the steps to reproduce the problem:
>>
>> 1. Initialize a new repository.
>> 2. Create a file with three lines of content each with the word
>> "Hello". Do not put a new line at the end of the file.
>> 3. Add and commit the file.
>> 4. Edit the same file putting words inbetween the three lines.
>> 5. Open git-gui and try to stage the changes line by line.
>>
>> The editor will append the warning "No newline at end of file” to the
>> end of the diff. When you are trying to stage a line an error occurs.
>> The problem is also illustrated in a question on Stackoverflow [1].
>>
>> Please let me know if you need more information or if I should send
>> this problem to some other mailing list.
>> Thank you, Tobias
>>
>> ____________
>> [1] http://stackoverflow.com/questions/13223868/how-to-stage-line-by-line-in-git-gui-although-no-newline-at-end-of-file-warnin
>

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] git-gui: allow "\ No newline at end of file" for linewise staging
  2013-01-09 14:49     ` Pat Thoyts
@ 2013-05-09 16:30       ` Heiko Voigt
  2013-05-10 19:09         ` Tobias Preuss
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Voigt @ 2013-05-09 16:30 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: Junio C Hamano, git, Tobias Preuss

Counting of lines did not skip this line when generating the hunk
header.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
Here is an attempt at fixing the no newline issue. I would appreciate
another pair of eyes though.

 git-gui/lib/diff.tcl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index ec44055..30d9a79 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -764,8 +764,15 @@ proc apply_range_or_line {x y} {
 				# context line
 				set ln [$ui_diff get $i_l $next_l]
 				set patch "$patch$pre_context$ln"
-				set n [expr $n+1]
-				set m [expr $m+1]
+				# Skip the "\ No newline at end of
+				# file". Depending on the locale setting
+				# we don't know what this line looks
+				# like exactly. The only thing we do
+				# know is that it starts with "\ "
+				if {![string match {\\ *} $ln]} {
+					set n [expr $n+1]
+					set m [expr $m+1]
+				}
 				set pre_context {}
 			} elseif {$c1 eq $to_context} {
 				# turn change line into context line
-- 
1.8.3.rc1.40.gba374ae

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-gui: allow "\ No newline at end of file" for linewise staging
  2013-05-09 16:30       ` [PATCH] git-gui: allow "\ No newline at end of file" for linewise staging Heiko Voigt
@ 2013-05-10 19:09         ` Tobias Preuss
  0 siblings, 0 replies; 5+ messages in thread
From: Tobias Preuss @ 2013-05-10 19:09 UTC (permalink / raw)
  To: Heiko Voigt; +Cc: Pat Thoyts, Junio C Hamano, git

I tested the patch as I am the same person that bothered about the
behavior a while ago. Please merge.
- Sorry for sending an HTML formatted mail before.

On Thu, May 9, 2013 at 6:30 PM, Heiko Voigt <hvoigt@hvoigt.net> wrote:
> Counting of lines did not skip this line when generating the hunk
> header.
>
> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
> ---
> Here is an attempt at fixing the no newline issue. I would appreciate
> another pair of eyes though.
>
>  git-gui/lib/diff.tcl | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
> index ec44055..30d9a79 100644
> --- a/git-gui/lib/diff.tcl
> +++ b/git-gui/lib/diff.tcl
> @@ -764,8 +764,15 @@ proc apply_range_or_line {x y} {
>                                 # context line
>                                 set ln [$ui_diff get $i_l $next_l]
>                                 set patch "$patch$pre_context$ln"
> -                               set n [expr $n+1]
> -                               set m [expr $m+1]
> +                               # Skip the "\ No newline at end of
> +                               # file". Depending on the locale setting
> +                               # we don't know what this line looks
> +                               # like exactly. The only thing we do
> +                               # know is that it starts with "\ "
> +                               if {![string match {\\ *} $ln]} {
> +                                       set n [expr $n+1]
> +                                       set m [expr $m+1]
> +                               }
>                                 set pre_context {}
>                         } elseif {$c1 eq $to_context} {
>                                 # turn change line into context line
> --
> 1.8.3.rc1.40.gba374ae
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-10 19:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13 20:26 git-gui / Warning: "No newline at end of file” Tobias Preuss
2013-01-03 12:26 ` Fwd: " Tobias Preuss
     [not found]   ` <7vzk0qw8ts.fsf@alter.siamese.dyndns.org>
2013-01-09 14:49     ` Pat Thoyts
2013-05-09 16:30       ` [PATCH] git-gui: allow "\ No newline at end of file" for linewise staging Heiko Voigt
2013-05-10 19:09         ` Tobias Preuss

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).