3363
}
3364
3365
sub format_paging_nav {
3366
- my ($action, $hash, $head, $page, $has_next_link) = @_;
3366
+ my ($action, $page, $has_next_link) = @_;
3367
my $paging_nav;
3368
3369
3370
- if ($hash ne $head || $page) {
3371
- $paging_nav .= $cgi->a({-href => href(action=>$action)}, "HEAD");
3372
- } else {
3373
- $paging_nav .= "HEAD";
3374
- }
3375
-
3370
if ($page > 0) {
3377
- $paging_nav .= " ⋅ " .
3371
+ $paging_nav .=
3372
+ $cgi->a({-href => href(-replay=>1, page=>undef)}, "first") .
3373
+ " ⋅ " .
3374
$cgi->a({-href => href(-replay=>1, page=>$page-1),
3375
-accesskey => "p", -title => "Alt-p"}, "prev");
3376
} else {
3381
- $paging_nav .= " ⋅ prev";
3377
+ $paging_nav .= "first ⋅ prev";
3378
}
3379
3380
if ($has_next_link) {
4443
4444
sub git_history_body {
4445
# Warning: assumes constant type (blob or tree) during history
4450
- my ($commitlist, $from, $to, $refs, $hash_base, $ftype, $extra) = @_;
4446
+ my ($commitlist, $from, $to, $refs, $extra,
4447
+ $file_name, $file_hash, $ftype) = @_;
4448
4449
$from = 0 unless defined $from;
4450
$to = $#{$commitlist} unless (defined $to && $to <= $#{$commitlist});
4478
$cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff");
4479
4480
if ($ftype eq 'blob') {
4484
- my $blob_current = git_get_hash_by_path($hash_base, $file_name);
4481
+ my $blob_current = $file_hash;
4482
my $blob_parent = git_get_hash_by_path($commit, $file_name);
4483
if (defined $blob_current && defined $blob_parent &&
4484
$blob_current ne $blob_parent) {
5335
}
5336
5337
sub git_log_generic {
5341
- my ($fmt_name, $body_subr) = @_;
5338
+ my ($fmt_name, $body_subr, $base, $parent, $file_name, $file_hash) = @_;
5339
5340
my $head = git_get_head_hash($project);
5344
- if (!defined $hash) {
5345
- $hash = $head;
5341
+ if (!defined $base) {
5342
+ $base = $head;
5343
}
5344
if (!defined $page) {
5345
$page = 0;
5346
}
5347
my $refs = git_get_references();
5348
5352
- my $commit_hash = $hash;
5353
- if (defined $hash_parent) {
5354
- $commit_hash = "$hash_parent..$hash";
5349
+ my $commit_hash = $base;
5350
+ if (defined $parent) {
5351
+ $commit_hash = "$parent..$base";
5352
+ }
5353
+ my @commitlist =
5354
+ parse_commits($commit_hash, 101, (100 * $page),
5355
+ defined $file_name ? ($file_name, "--full-history") : ());
5356
+
5357
+ my $ftype;
5358
+ if (!defined $file_hash && defined $file_name) {
5359
+ # some commits could have deleted file in question,
5360
+ # and not have it in tree, but one of them has to have it
5361
+ for (my $i = 0; $i < @commitlist; $i++) {
5362
+ $file_hash = git_get_hash_by_path($commitlist[$i]{'id'}, $file_name);
5363
+ last if defined $file_hash;
5364
+ }
5365
+ }
5366
+ if (defined $file_hash) {
5367
+ $ftype = git_get_type($file_hash);
5368
+ }
5369
+ if (defined $file_name && !defined $ftype) {
5370
+ die_error(500, "Unknown type of object");
5371
+ }
5372
+ my %co;
5373
+ if (defined $file_name) {
5374
+ %co = parse_commit($base)
5375
+ or die_error(404, "Unknown commit object");
5376
}
5356
- my @commitlist = parse_commits($commit_hash, 101, (100 * $page));
5377
5358
- my $paging_nav = format_paging_nav($fmt_name, $hash, $head,
5359
- $page, $#commitlist >= 100);
5378
+
5379
+ my $paging_nav = format_paging_nav($fmt_name, $page, $#commitlist >= 100);
5380
my $next_link = '';
5381
if ($#commitlist >= 100) {
5382
$next_link =
5384
-accesskey => "n", -title => "Alt-n"}, "next");
5385
}
5386
my $patch_max = gitweb_get_feature('patches');
5367
- if ($patch_max) {
5387
+ if ($patch_max && !defined $file_name) {
5388
if ($patch_max < 0 || @commitlist <= $patch_max) {
5389
$paging_nav .= " ⋅ " .
5390
$cgi->a({-href => href(action=>"patches", -replay=>1)},
5394
5395
git_header_html();
5396
git_print_page_nav($fmt_name,'', $hash,$hash,$hash, $paging_nav);
5377
- git_print_header_div('summary', $project);
5397
+ if (defined $file_name) {
5398
+ git_print_header_div('commit', esc_html($co{'title'}), $base);
5399
+ } else {
5400
+ git_print_header_div('summary', $project)
5401
+ }
5402
+ git_print_page_path($file_name, $ftype, $hash_base)
5403
+ if (defined $file_name);
5404
5379
- $body_subr->(\@commitlist, 0, 99, $refs, $next_link);
5405
+ $body_subr->(\@commitlist, 0, 99, $refs, $next_link,
5406
+ $file_name, $file_hash, $ftype);
5407
5408
git_footer_html();
5409
}
5410
5411
sub git_log {
5385
- git_log_generic('log', \&git_log_body);
5412
+ git_log_generic('log', \&git_log_body,
5413
+ $hash, $hash_parent);
5414
}
5415
5416
sub git_commit {
5949
}
5950
5951
sub git_history {
5924
- if (!defined $hash_base) {
5925
- $hash_base = git_get_head_hash($project);
5926
- }
5927
- if (!defined $page) {
5928
- $page = 0;
5929
- }
5930
- my $ftype;
5931
- my %co = parse_commit($hash_base)
5932
- or die_error(404, "Unknown commit object");
5933
-
5934
- my $refs = git_get_references();
5935
- my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
5936
-
5937
- my @commitlist = parse_commits($hash_base, 101, (100 * $page),
5938
- $file_name, "--full-history")
5939
- or die_error(404, "No such file or directory on given branch");
5940
-
5941
- if (!defined $hash && defined $file_name) {
5942
- # some commits could have deleted file in question,
5943
- # and not have it in tree, but one of them has to have it
5944
- for (my $i = 0; $i <= @commitlist; $i++) {
5945
- $hash = git_get_hash_by_path($commitlist[$i]{'id'}, $file_name);
5946
- last if defined $hash;
5947
- }
5948
- }
5949
- if (defined $hash) {
5950
- $ftype = git_get_type($hash);
5951
- }
5952
- if (!defined $ftype) {
5953
- die_error(500, "Unknown type of object");
5954
- }
5955
-
5956
- my $paging_nav = '';
5957
- if ($page > 0) {
5958
- $paging_nav .=
5959
- $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
5960
- file_name=>$file_name)},
5961
- "first");
5962
- $paging_nav .= " ⋅ " .
5963
- $cgi->a({-href => href(-replay=>1, page=>$page-1),
5964
- -accesskey => "p", -title => "Alt-p"}, "prev");
5965
- } else {
5966
- $paging_nav .= "first";
5967
- $paging_nav .= " ⋅ prev";
5968
- }
5969
- my $next_link = '';
5970
- if ($#commitlist >= 100) {
5971
- $next_link =
5972
- $cgi->a({-href => href(-replay=>1, page=>$page+1),
5973
- -accesskey => "n", -title => "Alt-n"}, "next");
5974
- $paging_nav .= " ⋅ $next_link";
5975
- } else {
5976
- $paging_nav .= " ⋅ next";
5977
- }
5978
-
5979
- git_header_html();
5980
- git_print_page_nav('history','', $hash_base,$co{'tree'},$hash_base, $paging_nav);
5981
- git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
5982
- git_print_page_path($file_name, $ftype, $hash_base);
5983
-
5984
- git_history_body(\@commitlist, 0, 99,
5985
- $refs, $hash_base, $ftype, $next_link);
5986
-
5987
- git_footer_html();
5952
+ git_log_generic('history', \&git_history_body,
5953
+ $hash_base, $hash_parent_base,
5954
+ $file_name, $hash);
5955
}
5956
5957
sub git_search {
6215
}
6216
6217
sub git_shortlog {
6251
- git_log_generic('shortlog', \&git_shortlog_body);
6218
+ git_log_generic('shortlog', \&git_shortlog_body,
6219
+ $hash, $hash_parent);
6220
}
6221
6222
## ......................................................................