From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Pat Thoyts <patthoyts@users.sourceforge.net>
Cc: git@vger.kernel.org, Bert Wesarg <bert.wesarg@googlemail.com>
Subject: [PATCH 1/1] git-gui: fix hunk parsing for corner case changes
Date: Mon, 9 Jan 2012 14:43:17 +0100 [thread overview]
Message-ID: <cccd6193cf3bfe170e14270204d735a842bb8563.1326116492.git.bert.wesarg@googlemail.com> (raw)
The simple hunk parsing code did not recognize hunks when there is no
second number after the comma. Like in these cases:
@@ -1 +0,0 @@
-1
Which resulted in this hunk header:
@@ -1 +0,1 +1 +0,0 @@
Or:
@@ -1 +1 @@
-1
+2
Resulted in:
@@ -1 +1 @@
,1 +1 +1 @@
,0 @@
While trying to stage only the '-1' line.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
lib/diff.tcl | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/diff.tcl b/lib/diff.tcl
index ec44055..63f8742 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -672,9 +672,11 @@ proc apply_range_or_line {x y} {
# $i_l is now at the beginning of a line
# pick start line number from hunk header
- set hh [$ui_diff get $i_l "$i_l + 1 lines"]
- set hh [lindex [split $hh ,] 0]
- set hln [lindex [split $hh -] 1]
+ if {![regexp {^@@ -(\d+)(?:,\d+)? \+(?:\d+)(?:,\d+)? @@(?:\s|$)} \
+ [$ui_diff get $i_l "$i_l + 1 lines"] hh hln]} {
+ unlock_index
+ return
+ }
# There is a special situation to take care of. Consider this
# hunk:
--
1.7.8.1.873.gfea665
next reply other threads:[~2012-01-09 13:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-09 13:43 Bert Wesarg [this message]
2012-01-09 13:43 ` [PATCH 2/2] git-gui: fix applying line/ranges when the selection ends at the begin of a line Bert Wesarg
2012-01-09 13:43 ` [RFC/PATCH 3/3] git-gui: support for reverting hunks and lines Bert Wesarg
2012-01-14 5:26 ` [PATCH 2/2] git-gui: fix applying line/ranges when the selection ends at the begin of a line Bert Wesarg
2012-01-14 7:00 ` Junio C Hamano
2012-01-14 11:23 ` Bert Wesarg
2012-01-14 12:08 ` Bert Wesarg
2012-01-14 5:25 ` [PATCH 1/1] git-gui: fix hunk parsing for corner case changes Bert Wesarg
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cccd6193cf3bfe170e14270204d735a842bb8563.1326116492.git.bert.wesarg@googlemail.com \
--to=bert.wesarg@googlemail.com \
--cc=git@vger.kernel.org \
--cc=patthoyts@users.sourceforge.net \
/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.
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).