X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/c49206138169eb63c4b143ff6c380cb6f3581a845b032f5934846317d68d2dab..9c9d435689da11f7e28170a9499e203e9cce56bb61c0846b9adb4e62091435f4:/gitweb.perl diff --git a/gitweb.perl b/gitweb.perl index 87806ac..b063714 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -749,6 +749,73 @@ sub git_get_references { return \%refs; } +sub git_get_following_references { + my $hash = shift || return undef; + my $type = shift; + my $base = shift || $hash_base || "HEAD"; + + my $refs = git_get_references($type); + open my $fd, "-|", $GIT, "rev-list", $base + or return undef; + my @commits = map { chomp; $_ } <$fd>; + close $fd + or return undef; + + my @reflist; + my $lastref; + + foreach my $commit (@commits) { + foreach my $ref (@{$refs->{$commit}}) { + $lastref = $ref; + push @reflist, $lastref; + } + if ($commit eq $hash) { + last; + } + } + + return wantarray ? @reflist : $lastref; +} + +sub git_get_preceding_references { + my $hash = shift || return undef; + my $type = shift; + + my $refs = git_get_references($type); + open my $fd, "-|", $GIT, "rev-list", $hash + or return undef; + my @commits = map { chomp; $_ } <$fd>; + close $fd + or return undef; + + my @reflist; + + foreach my $commit (@commits) { + foreach my $ref (@{$refs->{$commit}}) { + return $ref unless wantarray; + push @reflist, $ref; + } + } + + return @reflist; +} + +sub git_get_rev_name_tags { + my $hash = shift || return undef; + + open my $fd, "-|", $GIT, "name-rev", "--tags", $hash + or return; + my $name_rev = <$fd>; + close $fd; + + if ($name_rev =~ m|^$hash tags/(.*)$|) { + return $1; + } else { + # catches also '$hash undefined' output + return undef; + } +} + ## ---------------------------------------------------------------------- ## parse to hash functions @@ -1539,7 +1606,7 @@ sub git_difftree_body { } sub git_patchset_body { - my ($patchset, $difftree, $hash, $hash_parent) = @_; + my ($fd, $difftree, $hash, $hash_parent) = @_; my $patch_idx = 0; my $in_header = 0; @@ -1548,7 +1615,9 @@ sub git_patchset_body { print "