@matheusbsbs / matheus-bagliano / commits / 740e67f903
Fork 0

gitweb: Added parse_difftree_raw_line function for later use

Adds parse_difftree_raw_line function which parses one line of "raw" format diff-tree output into a hash. For later use in git_difftree_body, git_commitdiff and git_commitdiff_plain, git_search. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Aug 21, 2006 at 23:07 UTC 740e67f903ce738b25876f6d60faaff21f70fb4a
1 file changed +27
gitweb/gitweb.perl
+27
@@ -918,6 +918,33 @@ sub parse_ref {
918 return %ref_item;
919 }
920
921 +sub parse_difftree_raw_line {
922 + my $line = shift;
923 + my %res;
924 +
925 + # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
926 + # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
927 + if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/) {
928 + $res{'from_mode'} = $1;
929 + $res{'to_mode'} = $2;
930 + $res{'from_id'} = $3;
931 + $res{'to_id'} = $4;
932 + $res{'status'} = $5;
933 + $res{'similarity'} = $6;
934 + if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
935 + ($res{'from_file'}, $res{'to_file'}) = map(unquote, split("\t", $7));
936 + } else {
937 + $res{'file'} = unquote($7);
938 + }
939 + }
940 + # 'c512b523472485aef4fff9e57b229d9d243c967f'
941 + #elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
942 + # $res{'commit'} = $1;
943 + #}
944 +
945 + return wantarray ? %res : \%res;
946 +}
947 +
948 ## ......................................................................
949 ## parse to array of hashes functions
950