Skip to content

Commit 5ae917a

Browse files
jnarebJunio C Hamano
authored andcommitted
gitweb: Support comparing blobs (files) with different names
Fix the bug that caused "blobdiff" view called with new style URI for a rename with change diff to be show as new (added) file diff. New style URI for "blobdiff" for rename means with $hash_base ('hb') and $hash_parent_base ('hpb') paramaters denoting tree-ish (usually commit) of a blobs being compared, together with both $file_name ('f') and $file_parent ('fp') parameters. It is done by adding $file_parent ('fp') to the path limiter, meaning that diff command becomes: git diff-tree [options] hpb hb -- fp f Other option would be finding hash of a blob using git_get_hash_by_path subroutine and comparing blobs using git-diff, or using extended SHA-1 syntax and compare blobs using git-diff: git diff [options] hpb:fp hp:f Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent aa45321 commit 5ae917a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gitweb/gitweb.perl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,7 @@ sub git_blobdiff {
38853885
# read raw output
38863886
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
38873887
$hash_parent_base, $hash_base,
3888-
"--", $file_name
3888+
"--", (defined $file_parent ? $file_parent : ()), $file_name
38893889
or die_error(undef, "Open git-diff-tree failed");
38903890
@difftree = map { chomp; $_ } <$fd>;
38913891
close $fd
@@ -3935,7 +3935,7 @@ sub git_blobdiff {
39353935
# open patch output
39363936
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
39373937
'-p', $hash_parent_base, $hash_base,
3938-
"--", $file_name
3938+
"--", (defined $file_parent ? $file_parent : ()), $file_name
39393939
or die_error(undef, "Open git-diff-tree failed");
39403940
}
39413941

0 commit comments

Comments
 (0)