From: "Shawn O. Pearce" <spearce@spearce.org>
To: Alexander Gladysh <agladysh@gmail.com>
Cc: git-users@googlegroups.com, git@vger.kernel.org
Subject: Re: Git Gui does not want to work on chunk level
Date: Thu, 4 Sep 2008 21:53:27 -0700 [thread overview]
Message-ID: <20080905045327.GA31166@spearce.org> (raw)
In-Reply-To: <c6c947f60809040754g34e60633lcd5f872ac5e80158@mail.gmail.com>
Alexander Gladysh <agladysh@gmail.com> wrote:
>
> Aha! Thank you! That "--" is a comment in Lua (that is commented line
> that was removed in diff). First dash is from diff, next two came from
> file itself.
>
> Steps to reproduce the bug:
...
So that was an awesome reproduction case. I have committed the
following fix and will push it out in a few minutes:
--8<--
git-gui: Fix diff parsing for lines starting with "--" or "++"
Languages like Lua and SQL use "--" to mark a line as commented out.
If this appears at column 0 and is part of the pre-image we may see
"--- foo" in the diff, indicating that the line whose content is
"-- foo" has been removed from the new version.
git-gui was incorrectly parsing "--- foo" as the old file name
in the file header, causing it to generate a bad patch file when
the user tried to stage or unstage a hunk or the selected line.
We need to keep track of where we are in the parsing so that we do
not misread a deletion or addition record as part of the header.
Reported-by: Alexander Gladysh <agladysh@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
lib/diff.tcl | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/lib/diff.tcl b/lib/diff.tcl
index 4a7138b..1970b60 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -192,6 +192,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {
return
}
+ set ::current_diff_inheader 1
fconfigure $fd \
-blocking 0 \
-encoding binary \
@@ -207,18 +208,21 @@ proc read_diff {fd scroll_pos} {
while {[gets $fd line] >= 0} {
# -- Cleanup uninteresting diff header lines.
#
- if { [string match {diff --git *} $line]
- || [string match {diff --cc *} $line]
- || [string match {diff --combined *} $line]
- || [string match {--- *} $line]
- || [string match {+++ *} $line]} {
- append current_diff_header $line "\n"
- continue
+ if {$::current_diff_inheader} {
+ if { [string match {diff --git *} $line]
+ || [string match {diff --cc *} $line]
+ || [string match {diff --combined *} $line]
+ || [string match {--- *} $line]
+ || [string match {+++ *} $line]} {
+ append current_diff_header $line "\n"
+ continue
+ }
}
if {[string match {index *} $line]} continue
if {$line eq {deleted file mode 120000}} {
set line "deleted symlink"
}
+ set ::current_diff_inheader 0
# -- Automatically detect if this is a 3 way diff.
#
--
1.6.0.1.274.g007e4
--
Shawn.
next prev parent reply other threads:[~2008-09-05 4:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <c6c947f60808270216k2feb8f9ar765cdee1fc3910ee@mail.gmail.com>
[not found] ` <c6c947f60808270216k2feb8f9ar765cdee1fc3910ee-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-03 19:23 ` Git Gui does not want to work on chunk level Alexander Gladysh
2008-09-03 23:08 ` Shawn O. Pearce
2008-09-04 9:20 ` Alexander Gladysh
2008-09-04 14:37 ` Shawn O. Pearce
[not found] ` <20080904143723.GB23708-o8xcbExO1WpAfugRpC6u6w@public.gmane.org>
2008-09-04 14:54 ` Alexander Gladysh
2008-09-05 4:53 ` Shawn O. Pearce [this message]
2008-09-05 5:18 ` Junio C Hamano
2008-09-05 5:20 ` Shawn O. Pearce
[not found] ` <20080905045327.GA31166-o8xcbExO1WpAfugRpC6u6w@public.gmane.org>
2008-09-05 19:27 ` Alexander Gladysh
2008-09-15 7:08 ` Johannes Sixt
2010-11-30 21:19 ` Bert Wesarg
2010-11-30 22:20 ` Bert Wesarg
2010-12-06 21:30 ` Bert Wesarg
2008-09-15 14:21 ` Alexander Gladysh
[not found] ` <c6c947f60809150721m1ec11f10xc68ce39559398659-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-15 14:24 ` Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080905045327.GA31166@spearce.org \
--to=spearce@spearce.org \
--cc=agladysh@gmail.com \
--cc=git-users@googlegroups.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.