{"thread":{"id":"26010","subject":"[PATCH 2/8] git-gui: handle index lines only in the diff header","startedAt":"2010-12-09T20:47:52Z","lastAt":"2011-01-28T09:43:36Z","messageCount":9,"participants":["Bert Wesarg","Pat Thoyts"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"157725","messageId":"babc4fe91e54e3923baa6f08cc92ee8ea494e704.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":null,"subject":"[PATCH 1/8] git-gui: rework handling of diff header","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:52Z","receivedAt":"2010-12-09T20:47:52Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"The fix in ca53c3f (Fix diff parsing for lines starting with \"--\" or \"++\",\n2008-09-05) got a bug report from Johannes Sixt, that new files in the\nindex now looks like:\n\nnew file mode 100644\n--- /dev/null\n+++ b/foo\n@@ -0,0 +1 @@\n+foo\n\nThe introduced problem was that the 'in-diff-header'-flag was unconditially\ndisabled. Now it is only disabled when a hunk line is detected. And also\nre-enabled when we encounter a new diff header.\n\nThe second part solves also the issue reported by me for diffs with file\ntype changes (i.e. the ''error: Unhandled 2 way diff marker: {d}\"', which\ncomes from the second 'diff --git' line).\n\nReported-by: Johannes Sixt <j.sixt@viscovery.net>\nReported-by: Bert Wesarg <bert.wesarg@googlemail.com>\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n---\n\nCc: Johannes Sixt <j.sixt@viscovery.net>\n---\n foo          |    1 +\n lib/diff.tcl |   18 +++++++++++++++---\n 2 files changed, 16 insertions(+), 3 deletions(-)\n create mode 100644 foo\n\ndiff --git a/foo b/foo\nnew file mode 100644\nindex 0000000..257cc56\n--- /dev/null\n+++ b/foo\n@@ -0,0 +1 @@\n+foo\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 9d0dc07..dae6ca6 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -382,23 +382,35 @@ proc read_diff {fd conflict_size cont_info} {\n \t\tforeach {line markup} [parse_color_line $line] break\n \t\tset line [string map {\\033 ^} $line]\n \n-\t\t# -- Cleanup uninteresting diff header lines.\n+\t\t# -- Check for start of diff header.\n+\t\tif {   [string match {diff --git *}      $line]\n+\t\t    || [string match {diff --cc *}       $line]\n+\t\t    || [string match {diff --combined *} $line]} {\n+\t\t\tset ::current_diff_inheader 1\n+\t\t}\n+\n+\t\t# -- Check for end of diff header (any hunk line will do this).\n \t\t#\n+\t\tif {[regexp {^@@+ } $line]} {set ::current_diff_inheader 0}\n+\n \t\tif {$::current_diff_inheader} {\n+\t\t\tappend current_diff_header $line \"\\n\"\n+\n+\t\t\t# -- Cleanup uninteresting diff header lines.\n+\t\t\t#\n \t\t\tif {   [string match {diff --git *}      $line]\n \t\t\t    || [string match {diff --cc *}       $line]\n \t\t\t    || [string match {diff --combined *} $line]\n \t\t\t    || [string match {--- *}             $line]\n \t\t\t    || [string match {+++ *}             $line]} {\n-\t\t\t\tappend current_diff_header $line \"\\n\"\n \t\t\t\tcontinue\n \t\t\t}\n \t\t}\n+\n \t\tif {[string match {index *} $line]} continue\n \t\tif {$line eq {deleted file mode 120000}} {\n \t\t\tset line \"deleted symlink\"\n \t\t}\n-\t\tset ::current_diff_inheader 0\n \n \t\t# -- Automatically detect if this is a 3 way diff.\n \t\t#\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"157719","messageId":"56141ad4622dfc1ee991c9ee3be90dbf3e99b744.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":"babc4fe91e54e3923baa6f08cc92ee8ea494e704.1291927657.git.bert.wesarg@googlemail.com","subject":"[PATCH 2/8] git-gui: handle index lines only in the diff header","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:53Z","receivedAt":"2010-12-09T20:47:53Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex dae6ca6..0b72924 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -402,12 +402,12 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t    || [string match {diff --cc *}       $line]\n \t\t\t    || [string match {diff --combined *} $line]\n \t\t\t    || [string match {--- *}             $line]\n-\t\t\t    || [string match {+++ *}             $line]} {\n+\t\t\t    || [string match {+++ *}             $line]\n+\t\t\t    || [string match {index *}           $line]} {\n \t\t\t\tcontinue\n \t\t\t}\n \t\t}\n \n-\t\tif {[string match {index *} $line]} continue\n \t\tif {$line eq {deleted file mode 120000}} {\n \t\t\tset line \"deleted symlink\"\n \t\t}\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"157724","messageId":"ae1d2af4dad878c54959a72989cb170376b7fb95.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":"56141ad4622dfc1ee991c9ee3be90dbf3e99b744.1291927657.git.bert.wesarg@googlemail.com","subject":"[PATCH 3/8] git-gui: name also new symlinks so","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:54Z","receivedAt":"2010-12-09T20:47:54Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"and rename them only in the diff header\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 0b72924..aa30089 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -406,12 +406,13 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t    || [string match {index *}           $line]} {\n \t\t\t\tcontinue\n \t\t\t}\n-\t\t}\n \n-\t\tif {$line eq {deleted file mode 120000}} {\n-\t\t\tset line \"deleted symlink\"\n+\t\t\t# -- Name it symlink, not 120000\n+\t\t\t#    Note, that the original line is in $current_diff_header\n+\t\t\tregsub {^(deleted|new) file mode 120000} $line {\\1 symlink} line\n \t\t}\n \n+\n \t\t# -- Automatically detect if this is a 3 way diff.\n \t\t#\n \t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n@@ -421,6 +422,7 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t|| [regexp {^(old|new) mode *} $line]\n \t\t\t|| [string match {deleted file *} $line]\n \t\t\t|| [string match {deleted symlink} $line]\n+\t\t\t|| [string match {new symlink} $line]\n \t\t\t|| [string match {Binary files * and * differ} $line]\n \t\t\t|| $line eq {\\ No newline at end of file}\n \t\t\t|| [regexp {^\\* Unmerged path } $line]} {\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"157720","messageId":"cc7284fbd48c589af26dd8f3905fb4244fedbfda.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":"ae1d2af4dad878c54959a72989cb170376b7fb95.1291927657.git.bert.wesarg@googlemail.com","subject":"[PATCH 4/8] git-gui: there is no \"mode *\" diff header line","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:55Z","receivedAt":"2010-12-09T20:47:55Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex aa30089..20f50dd 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -417,8 +417,7 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t#\n \t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n \n-\t\tif {[string match {mode *} $line]\n-\t\t\t|| [string match {new file *} $line]\n+\t\tif {[string match {new file *} $line]\n \t\t\t|| [regexp {^(old|new) mode *} $line]\n \t\t\t|| [string match {deleted file *} $line]\n \t\t\t|| [string match {deleted symlink} $line]\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"157726","messageId":"96986a5a805579d1e341fd0f5fa44ccf9b98b312.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":"cc7284fbd48c589af26dd8f3905fb4244fedbfda.1291927657.git.bert.wesarg@googlemail.com","subject":"[PATCH 5/8] git-gui: move 3way diff autodetect up","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:56Z","receivedAt":"2010-12-09T20:47:56Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 20f50dd..2290919 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -393,6 +393,10 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t#\n \t\tif {[regexp {^@@+ } $line]} {set ::current_diff_inheader 0}\n \n+\t\t# -- Automatically detect if this is a 3 way diff.\n+\t\t#\n+\t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n+\n \t\tif {$::current_diff_inheader} {\n \t\t\tappend current_diff_header $line \"\\n\"\n \n@@ -413,9 +417,6 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t}\n \n \n-\t\t# -- Automatically detect if this is a 3 way diff.\n-\t\t#\n-\t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n \n \t\tif {[string match {new file *} $line]\n \t\t\t|| [regexp {^(old|new) mode *} $line]\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"157721","messageId":"83035737417287ef9f1ad246e269f0e31dbe5e03.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":"96986a5a805579d1e341fd0f5fa44ccf9b98b312.1291927657.git.bert.wesarg@googlemail.com","subject":"[PATCH 6/8] git-gui: always reset the current tag","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:57Z","receivedAt":"2010-12-09T20:47:57Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 2290919..91ed7c6 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -382,6 +382,8 @@ proc read_diff {fd conflict_size cont_info} {\n \t\tforeach {line markup} [parse_color_line $line] break\n \t\tset line [string map {\\033 ^} $line]\n \n+\t\tset tags {}\n+\n \t\t# -- Check for start of diff header.\n \t\tif {   [string match {diff --git *}      $line]\n \t\t    || [string match {diff --cc *}       $line]\n@@ -426,7 +428,6 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t|| [string match {Binary files * and * differ} $line]\n \t\t\t|| $line eq {\\ No newline at end of file}\n \t\t\t|| [regexp {^\\* Unmerged path } $line]} {\n-\t\t\tset tags {}\n \t\t} elseif {$is_3way_diff} {\n \t\t\tset op [string range $line 0 1]\n \t\t\tswitch -- $op {\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"157723","messageId":"6581252c19fb2c89a7f2d3e77e62b32f689d5e38.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":"83035737417287ef9f1ad246e269f0e31dbe5e03.1291927657.git.bert.wesarg@googlemail.com","subject":"[PATCH 7/8] git-gui: handle special content lines only in the diff header section","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:58Z","receivedAt":"2010-12-09T20:47:58Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"These two also stop the diff header.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl |   15 +++++++++------\n 1 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 91ed7c6..4eaf7e7 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -400,7 +400,14 @@ proc read_diff {fd conflict_size cont_info} {\n \t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n \n \t\tif {$::current_diff_inheader} {\n-\t\t\tappend current_diff_header $line \"\\n\"\n+\n+\t\t\t# -- These two lines stop a diff header and shouldn't be in there\n+\t\t\tif {   [string match {Binary files * and * differ} $line]\n+\t\t\t    || [regexp {^\\* Unmerged path }                $line]} {\n+\t\t\t\tset ::current_diff_inheader 0\n+\t\t\t} else {\n+\t\t\t\tappend current_diff_header $line \"\\n\"\n+\t\t\t}\n \n \t\t\t# -- Cleanup uninteresting diff header lines.\n \t\t\t#\n@@ -418,16 +425,12 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\tregsub {^(deleted|new) file mode 120000} $line {\\1 symlink} line\n \t\t}\n \n-\n-\n \t\tif {[string match {new file *} $line]\n \t\t\t|| [regexp {^(old|new) mode *} $line]\n \t\t\t|| [string match {deleted file *} $line]\n \t\t\t|| [string match {deleted symlink} $line]\n \t\t\t|| [string match {new symlink} $line]\n-\t\t\t|| [string match {Binary files * and * differ} $line]\n-\t\t\t|| $line eq {\\ No newline at end of file}\n-\t\t\t|| [regexp {^\\* Unmerged path } $line]} {\n+\t\t\t|| $line eq {\\ No newline at end of file}} {\n \t\t} elseif {$is_3way_diff} {\n \t\t\tset op [string range $line 0 1]\n \t\t\tswitch -- $op {\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"157722","messageId":"1917eb763e2d36b2d512608ca1546571c8d478ad.1291927657.git.bert.wesarg@googlemail.com","threadId":"26010","inReplyTo":"6581252c19fb2c89a7f2d3e77e62b32f689d5e38.1291927657.git.bert.wesarg@googlemail.com","subject":"[PATCH 8/8] git-gui: handle meta diff header lines only in the header section","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-09T20:47:59Z","receivedAt":"2010-12-09T20:47:59Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl |    9 ++-------\n 1 files changed, 2 insertions(+), 7 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 4eaf7e7..cf8a95e 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -423,14 +423,9 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t# -- Name it symlink, not 120000\n \t\t\t#    Note, that the original line is in $current_diff_header\n \t\t\tregsub {^(deleted|new) file mode 120000} $line {\\1 symlink} line\n-\t\t}\n \n-\t\tif {[string match {new file *} $line]\n-\t\t\t|| [regexp {^(old|new) mode *} $line]\n-\t\t\t|| [string match {deleted file *} $line]\n-\t\t\t|| [string match {deleted symlink} $line]\n-\t\t\t|| [string match {new symlink} $line]\n-\t\t\t|| $line eq {\\ No newline at end of file}} {\n+\t\t} elseif {   $line eq {\\ No newline at end of file}} {\n+\t\t\t# -- Handle some special lines\n \t\t} elseif {$is_3way_diff} {\n \t\t\tset op [string range $line 0 1]\n \t\t\tswitch -- $op {\n-- \n1.7.3.2.1200.ge4bf6\n"},{"id":"159974","messageId":"87r5bx5po7.fsf@fox.patthoyts.tk","threadId":"26010","inReplyTo":"babc4fe91e54e3923baa6f08cc92ee8ea494e704.1291927657.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 1/8] git-gui: rework handling of diff header","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2011-01-28T09:43:36Z","receivedAt":"2011-01-28T09:43:36Z","isPatch":true,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n>The fix in ca53c3f (Fix diff parsing for lines starting with \"--\" or \"++\",\n>2008-09-05) got a bug report from Johannes Sixt, that new files in the\n>index now looks like:\n>\n>new file mode 100644\n>--- /dev/null\n>+++ b/foo\n>@@ -0,0 +1 @@\n>+foo\n\nInlining this in the commit comment causes 'git am' to terminate the\ncomment text early. You should add some leading space when putting text\nthat looks like patch header into this section.\n>\n>The introduced problem was that the 'in-diff-header'-flag was unconditially\n>disabled. Now it is only disabled when a hunk line is detected. And also\n>re-enabled when we encounter a new diff header.\n>\n>The second part solves also the issue reported by me for diffs with file\n>type changes (i.e. the ''error: Unhandled 2 way diff marker: {d}\"', which\n>comes from the second 'diff --git' line).\n>\n>Reported-by: Johannes Sixt <j.sixt@viscovery.net>\n>Reported-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>\n>---\n>\n>Cc: Johannes Sixt <j.sixt@viscovery.net>\n>---\n> foo          |    1 +\n> lib/diff.tcl |   18 +++++++++++++++---\n> 2 files changed, 16 insertions(+), 3 deletions(-)\n> create mode 100644 foo\n>\n>diff --git a/foo b/foo\n>new file mode 100644\n>index 0000000..257cc56\n>--- /dev/null\n>+++ b/foo\n>@@ -0,0 +1 @@\n>+foo\n\nWe don't need a 'foo' file :)\n\n>diff --git a/lib/diff.tcl b/lib/diff.tcl\n>index 9d0dc07..dae6ca6 100644\n>--- a/lib/diff.tcl\n>+++ b/lib/diff.tcl\n>@@ -382,23 +382,35 @@ proc read_diff {fd conflict_size cont_info} {\n> \t\tforeach {line markup} [parse_color_line $line] break\n> \t\tset line [string map {\\033 ^} $line]\n> \n>-\t\t# -- Cleanup uninteresting diff header lines.\n>+\t\t# -- Check for start of diff header.\n>+\t\tif {   [string match {diff --git *}      $line]\n>+\t\t    || [string match {diff --cc *}       $line]\n>+\t\t    || [string match {diff --combined *} $line]} {\n>+\t\t\tset ::current_diff_inheader 1\n>+\t\t}\n>+\n>+\t\t# -- Check for end of diff header (any hunk line will do this).\n> \t\t#\n>+\t\tif {[regexp {^@@+ } $line]} {set ::current_diff_inheader 0}\n>+\n> \t\tif {$::current_diff_inheader} {\n>+\t\t\tappend current_diff_header $line \"\\n\"\n>+\n>+\t\t\t# -- Cleanup uninteresting diff header lines.\n>+\t\t\t#\n> \t\t\tif {   [string match {diff --git *}      $line]\n> \t\t\t    || [string match {diff --cc *}       $line]\n> \t\t\t    || [string match {diff --combined *} $line]\n> \t\t\t    || [string match {--- *}             $line]\n> \t\t\t    || [string match {+++ *}             $line]} {\n>-\t\t\t\tappend current_diff_header $line \"\\n\"\n> \t\t\t\tcontinue\n> \t\t\t}\n> \t\t}\n>+\n> \t\tif {[string match {index *} $line]} continue\n> \t\tif {$line eq {deleted file mode 120000}} {\n> \t\t\tset line \"deleted symlink\"\n> \t\t}\n>-\t\tset ::current_diff_inheader 0\n> \n> \t\t# -- Automatically detect if this is a 3 way diff.\n> \t\t#\n\nThe patch series 1 to 8 are fine. I've taken them without the foo file\nmentioned above and adding some spaces to the commit comment as noted\nabove. This replaces a couple of tentative patches we've discussed\npreviously for errors on stderr when symlinks replace files.\nThank you - applying to master.\n\n-- \nPat Thoyts                            http://www.patthoyts.tk/\nPGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD\n"}]}