gitweb: Use git-diff-tree or git-diff patch output for blobdiff
This is second part of removing gitweb dependency on external
diff (used in git_diff_print).
Get rid of git_diff_print invocation in git_blobdiff, and use either
git-diff-tree (when both hash_base and hash_parent_base are provided)
patch format or git-diff patch format (when only hash and hash_parent
are provided) for output.
Supported URI schemes, and output formats:
* New URI scheme: both hash_base and hash_parent_base (trees-ish
containing blobs versions we want to compare) are provided.
Also either filename is provided, or hash (of blob) is provided
(we try to find filename then).
For this scheme we have copying and renames detection, mode changes,
file types etc., and information extended diff header is correct.
* Old URI scheme: hash_parent_base is not provided, we use hash and
hash_parent to directly compare blobs using git-diff. If no filename
is given, blobs hashes are used in place of filenames.
This scheme has always "blob" as file type, it cannot detect mode
changes, and we rely on CGI parameters to provide name of the file.
Added git_to_hash subroutine, which transforms symbolic name or list
of symbolic name to hash or list of hashes using git-rev-parse.
To have "blob" instead of "unknown" (or "file" regardless of the type)
in "gitweb diff header" for legacy scheme, file_type function now
returns its argument if it is not octal string.
Added support for fake "2" status code in git_patchset_body. Such code
is generated by git_blobdiff in legacy scheme case.
ATTENTION: The order of arguments (operands) to git-diff is reversed
(sic!) to have correct diff in the legacy (no hash_parent_base) case.
$hash_parent, $hash ordering is commented out, as it gives reversed
patch (at least for git version 1.4.1.1) as compared to output in new
scheme and output of older gitweb version.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>