diff options
author | Bert Wesarg <bert.wesarg@googlemail.com> | 2010-12-09 21:47:52 +0100 |
---|---|---|
committer | Pat Thoyts <patthoyts@users.sourceforge.net> | 2011-01-28 09:01:17 +0000 |
commit | c976bbff3c3e46e700adbdc14def8c9432fc925c (patch) | |
tree | 31d974690f2ce5282e467f0c56188ab14bf7b446 /lib | |
parent | 7587f4d32f7479a9fa9ae1767708597702a0be5f (diff) | |
download | git-c976bbff3c3e46e700adbdc14def8c9432fc925c.tar.gz |
git-gui: rework handling of diff header
The fix in ca53c3f (Fix diff parsing for lines starting with "--" or "++",
2008-09-05) got a bug report from Johannes Sixt, that new files in the
index now looks like:
new file mode 100644
--- /dev/null
+++ b/foo
@@ -0,0 +1 @@
+foo
The introduced problem was that the 'in-diff-header'-flag was unconditially
disabled. Now it is only disabled when a hunk line is detected. And also
re-enabled when we encounter a new diff header.
The second part solves also the issue reported by me for diffs with file
type changes (i.e. the ''error: Unhandled 2 way diff marker: {d}"', which
comes from the second 'diff --git' line).
Reported-by: Johannes Sixt <j.sixt@viscovery.net>
Reported-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diff.tcl | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl index 9d0dc07d7b..dae6ca6831 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -382,23 +382,35 @@ proc read_diff {fd conflict_size cont_info} { foreach {line markup} [parse_color_line $line] break set line [string map {\033 ^} $line] - # -- Cleanup uninteresting diff header lines. + # -- Check for start of diff header. + if { [string match {diff --git *} $line] + || [string match {diff --cc *} $line] + || [string match {diff --combined *} $line]} { + set ::current_diff_inheader 1 + } + + # -- Check for end of diff header (any hunk line will do this). # + if {[regexp {^@@+ } $line]} {set ::current_diff_inheader 0} + if {$::current_diff_inheader} { + append current_diff_header $line "\n" + + # -- 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 {[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. # |