aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-08-31 03:25:29 +0200
committerKay Sievers <kay.sievers@suse.de>2005-08-31 03:25:29 +0200
commita48e11ca90ff0cb01bff953ab4095a33a5561a70 (patch)
treef5f2919dbfb89eaa047d1d4c11fab71ac9f1ee74
parente00c9e18a7382209b158efdc0c600165cde295a5 (diff)
downloadgit-a48e11ca90ff0cb01bff953ab4095a33a5561a70.tar.gz
git-a48e11ca90ff0cb01bff953ab4095a33a5561a70.tar.xz
don't chop_str if adding ... is longer than the original
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
-rwxr-xr-xgitweb.cgi17
1 files changed, 10 insertions, 7 deletions
diff --git a/gitweb.cgi b/gitweb.cgi
index e68368d56..6ce922333 100755
--- a/gitweb.cgi
+++ b/gitweb.cgi
@@ -21,8 +21,8 @@ my $my_uri = $cgi->url(-absolute => 1);
my $rss_link = "";
# absolute fs-path which will be prepended to the project path
-my $projectroot = "/pub/scm";
-$projectroot = "/home/kay/public_html/pub/scm";
+#my $projectroot = "/pub/scm";
+my $projectroot = "/home/kay/public_html/pub/scm";
# location of the git-core binaries
my $gitbin = "/usr/bin";
@@ -621,12 +621,15 @@ sub chop_str {
my $len = shift;
my $add_len = shift || 10;
- $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})/;
- my $chopped = $1;
- if ($chopped ne $str) {
- $chopped .= " ...";
+ # allow only $len chars, but don't cut a word if it would fit in $add_len
+ # if it doesn't fit, cut it if it's still longer than the dots we would add
+ $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})(.*)/;
+ my $body = $1;
+ my $tail = $2;
+ if (length($tail) > 4) {
+ $tail = " ...";
}
- return $chopped;
+ return "$body$tail";
}
sub file_type {