git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/1] git-gui: fix hunk parsing for corner case changes
@ 2012-01-09 13:43 Bert Wesarg
  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-14  5:25 ` [PATCH 1/1] git-gui: fix hunk parsing for corner case changes Bert Wesarg
  0 siblings, 2 replies; 8+ messages in thread
From: Bert Wesarg @ 2012-01-09 13:43 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: git, Bert Wesarg

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

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

end of thread, other threads:[~2012-01-14 12:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-09 13:43 [PATCH 1/1] git-gui: fix hunk parsing for corner case changes Bert Wesarg
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

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).