gitweb: Fix and simplify "split patch" detectionAttic/gitweb/Simplify-split-patch-detection
commit5cf37cfa0d434a8ab1b6f5b8e1599a433213dd36
authorJakub Narebski <jnareb@gmail.com>
Fri, 7 Sep 2007 18:22:53 +0000 (7 20:22 +0200)
committerJakub Narebski <jnareb@gmail.com>
Fri, 7 Sep 2007 18:22:53 +0000 (7 20:22 +0200)
tree1fc68bcdc0c3a03f1da1af1ee62f40ab777f5861
parent1e61b7640d09015213dbcae3564fa27ac6a8c151
gitweb: Fix and simplify "split patch" detection

There are some cases when one line from "raw" git-diff output (raw format)
corresponds to more than one patch in the patchset git-diff output; we
call this situation "split patch". Current code misdetected subsequent
patches (for different files) with the same pre-image and post-image
as fragments of "split patch", leading to mislabeled from-file/to-file
diff header etc.

We could parse from_file and to_file (if to_file exists) from the "git
diff header" in the patch, i.e. from the "^diff" line in patchset, and
consider patch "split" or "continued" if not only pre-image and
post-image (from_id and to_id) matches, but only when also from_file
and to_file (if it exists) matches.  This has the advantage of being
generic, not depending on details of git diff output formatting, and
how patch output relates to raw diff output, but it adds yet another
complication.

Note: both from_name and to_name can be quoted and contain spaces;
their separation is nontrivial.

Alternate solution, which we did chose, is to check when git splits
patches, and do not check if parsed info from current patch corresponds
to current or next raw diff format output line.  Git splits patches
only for 'T' (typechange) status filepair, and there always two patches
corresponding to one raw diff line.

And we can get rid of buffering extended diff header and parsing it,
This simplifies git_patchset_body, making it easier to understand and
maintain.  At the other hand it fixes gitweb to git diff output details.

While at it we added 'status_str' to diffinfo output, which stores
status (also for merge commit) as a string.  This allows for easy
checking if there is given status among all for merge commit, e.g.
  $diffinfo->{'status_str'} =~ /T/

There are no users of from_ids_eq subroutine.

Noticed-by: Yann Dirson <ydirson@altern.org>
Diagnosed-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
gitweb/gitweb.perl