git-gui: rework handling of diff header
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 <b747394f430b0579c40c060c498ed893fb65b696@viscovery.net>
Reported-by: Bert Wesarg <0d62a3713d750bb3a7440aad892eb1fd24c11fa3@googlemail.com>
Signed-off-by: Bert Wesarg <0d62a3713d750bb3a7440aad892eb1fd24c11fa3@googlemail.com>
Signed-off-by: Pat Thoyts <fe43a83262eef1680511f524a1e74d43c633cffe@users.sourceforge.net>

destenson/git,destenson/git,destenson/git,destenson/git,destenson/git,destenson/git,destenson/git,destenson/git