]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Support comparing blobs (files) with different names
authorJakub Narebski <redacted>
Fri, 30 Mar 2007 21:41:26 +0000 (23:41 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:11 +0000 (00:07 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index f6c5f29cbdb4a537ff6110862c39d1dec79435734459683e44427e491c4ee7a6..4ee59fa4f9b46454a00e5ceda5ca81585f24401612e9e9859d61a0252bc8215c 100755 (executable)
@@ -3886,7 +3886,7 @@ sub git_blobdiff {
                        # read raw output
                        open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
                                $hash_parent_base, $hash_base,
                        # read raw output
                        open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
                                $hash_parent_base, $hash_base,
-                               "--", $file_name
+                               "--", (defined $file_parent ? $file_parent : ()), $file_name
                                or die_error(undef, "Open git-diff-tree failed");
                        @difftree = map { chomp; $_ } <$fd>;
                        close $fd
                                or die_error(undef, "Open git-diff-tree failed");
                        @difftree = map { chomp; $_ } <$fd>;
                        close $fd
@@ -3936,7 +3936,7 @@ sub git_blobdiff {
                # open patch output
                open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
                        '-p', $hash_parent_base, $hash_base,
                # open patch output
                open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
                        '-p', $hash_parent_base, $hash_base,
-                       "--", $file_name
+                       "--", (defined $file_parent ? $file_parent : ()), $file_name
                        or die_error(undef, "Open git-diff-tree failed");
        }
 
                        or die_error(undef, "Open git-diff-tree failed");
        }
 
This page took 0.180729 seconds and 4 git commands to generate.