patches: update gitweb patch set
[git-osx-installer.git] / patches / gitweb / q / gitweb-show-hash-for-displayed-objects.diff
blob25eada52909fae3b0d283b57c8cc5691e7605e62
1 Subject: [PATCH] gitweb: show hash for displayed objects
3 If gitweb is displaying a tag, tree or blob via a ref
4 name rather than a hash, it's impossible to actually see
5 the hash of the item.
7 Therefore always show the item type and hash id as the
8 first line of data. This means the commit hash will be
9 moved to the top to be consistent with the others.
11 Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
12 ---
13 gitweb/gitweb.perl | 25 ++++++++++++++++++++++++-
14 1 file changed, 24 insertions(+), 1 deletion(-)
16 diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
17 index a502664d..a3b85d5e 100755
18 --- a/gitweb/gitweb.perl
19 +++ b/gitweb/gitweb.perl
20 @@ -7398,12 +7398,17 @@ sub git_tag {
21 die_error(404, "Unknown tag object");
24 + my $fullhash;
25 + $fullhash = $hash if $hash =~ m/^[0-9a-fA-F]{40}$/;
26 + $fullhash = git_get_full_hash($project, $hash) unless $fullhash;
28 my $head = git_get_head_hash($project);
29 git_header_html();
30 git_print_page_nav('','', $head,undef,$head);
31 git_print_header_div('commit', esc_html($tag{'name'}), $hash);
32 print "<div class=\"title_text\">\n" .
33 "<table class=\"object_header\">\n" .
34 + "<tr><td>tag</td><td class=\"sha1\">$fullhash</td></tr>\n" .
35 "<tr>\n" .
36 "<td>object</td>\n" .
37 "<td>" . $cgi->a({-class => "list", -href => href(action=>$tag{'type'}, hash=>$tag{'object'})},
38 @@ -7827,18 +7832,22 @@ sub git_blob_plain {
39 sub git_blob {
40 my $expires;
42 + my $fullhash;
43 if (!defined $hash) {
44 if (defined $file_name) {
45 my $base = $hash_base || git_get_head_hash($project);
46 $hash = git_get_hash_by_path($base, $file_name, "blob")
47 or die_error(404, "Cannot find file");
48 + $fullhash = $hash;
49 } else {
50 die_error(400, "No file name defined");
52 } elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
53 # blobs defined by non-textual hash id's can be cached
54 $expires = "+1d";
55 + $fullhash = $hash;
57 + $fullhash = git_get_full_hash($project, $hash) unless $fullhash;
59 my $have_blame = gitweb_check_feature('blame');
60 defined(my $fd = git_cmd_pipe "cat-file", "blob", $hash)
61 @@ -7892,6 +7901,11 @@ sub git_blob {
62 "<div class=\"title\">".esc_html($hash)."</div>\n";
64 git_print_page_path($file_name, "blob", $hash_base);
65 + print "<div class=\"title_text\">\n" .
66 + "<table class=\"object_header\">\n";
67 + print "<tr><td>blob</td><td class=\"sha1\">$fullhash</td></tr>\n";
68 + print "</table>".
69 + "</div>\n";
70 print "<div class=\"page_body\">\n";
71 if ($mimetype =~ m!^image/!) {
72 print qq!<img class="blob" type="!.esc_attr($mimetype).qq!"!;
73 @@ -7920,17 +7934,21 @@ sub git_blob {
76 sub git_tree {
77 + my $fullhash;
78 if (!defined $hash_base) {
79 $hash_base = "HEAD";
81 if (!defined $hash) {
82 if (defined $file_name) {
83 $hash = git_get_hash_by_path($hash_base, $file_name, "tree");
84 + $fullhash = $hash;
85 } else {
86 $hash = $hash_base;
89 die_error(404, "No such tree") unless defined($hash);
90 + $fullhash = $hash if !$fullhash && $hash =~ m/^[0-9a-fA-F]{40}$/;
91 + $fullhash = git_get_full_hash($project, $hash) unless $fullhash;
93 my $show_sizes = gitweb_check_feature('show-sizes');
94 my $have_blame = gitweb_check_feature('blame');
95 @@ -7981,6 +7999,11 @@ sub git_tree {
97 git_print_page_path($file_name, 'tree', $hash_base);
99 + print "<div class=\"title_text\">\n" .
100 + "<table class=\"object_header\">\n";
101 + print "<tr><td>tree</td><td class=\"sha1\">$fullhash</td></tr>\n";
102 + print "</table>".
103 + "</div>\n";
104 print "<div class=\"page_body\">\n";
105 print "<table class=\"tree\">\n";
106 my $alternate = 1;
107 @@ -8324,8 +8347,8 @@ sub git_commit {
109 print "<div class=\"title_text\">\n" .
110 "<table class=\"object_header\">\n";
111 - git_print_authorship_rows(\%co);
112 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
113 + git_print_authorship_rows(\%co);
114 print "<tr>" .
115 "<td>tree</td>" .
116 "<td class=\"sha1\">" .