git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/8] git-gui: rework handling of diff header

From
Pat Thoyts <patthoyts@users.sourceforge.net>
Date
Jan 28, 2011, 09:43 UTC
Message-ID
<87r5bx5po7.fsf@fox.patthoyts.tk>
In-Reply-To
<babc4fe91e54e3923baa6f08cc92ee8ea494e704.1291927657.git.bert.wesarg@googlemail.com>
Bert Wesarg <bert.wesarg@googlemail.com> writes:
Show 9 quoted lines
>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

Inlining this in the commit comment causes 'git am' to terminate the comment text early. You should add some leading space when putting text that looks like patch header into this section.

Show 29 quoted lines
>
>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>
>
>---
>
>Cc: Johannes Sixt <j.sixt@viscovery.net>
>---
> foo          |    1 +
> lib/diff.tcl |   18 +++++++++++++++---
> 2 files changed, 16 insertions(+), 3 deletions(-)
> create mode 100644 foo
>
>diff --git a/foo b/foo
>new file mode 100644
>index 0000000..257cc56
>--- /dev/null
>+++ b/foo
>@@ -0,0 +1 @@
>+foo
We don't need a 'foo' file :)
Show 43 quoted lines
>diff --git a/lib/diff.tcl b/lib/diff.tcl
>index 9d0dc07..dae6ca6 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.
> 		#

The patch series 1 to 8 are fine. I've taken them without the foo file mentioned above and adding some spaces to the commit comment as noted above. This replaces a couple of tentative patches we've discussed previously for errors on stderr when symlinks replace files. Thank you - applying to master.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
Previous: Bert Wesarg
Message 9 of 9 in “git-gui: rework handling of diff header”
  1. 1/8 git-gui: rework handling of diff headerBert Wesarg, Dec 9, 2010
  2. 2/8 git-gui: handle index lines only in the diff headerBert Wesarg, Dec 9, 2010
  3. 3/8 git-gui: name also new symlinks soBert Wesarg, Dec 9, 2010
  4. 4/8 git-gui: there is no "mode *" diff header lineBert Wesarg, Dec 9, 2010
  5. 5/8 git-gui: move 3way diff autodetect upBert Wesarg, Dec 9, 2010
  6. 6/8 git-gui: always reset the current tagBert Wesarg, Dec 9, 2010
  7. 7/8 git-gui: handle special content lines only in the diff header sectionBert Wesarg, Dec 9, 2010
  8. 8/8 git-gui: handle meta diff header lines only in the header sectionBert Wesarg, Dec 9, 2010
  9. Pat ThoytsJan 28, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.