From: Magnus Hagander <magnus@hagander.net>
To: git@vger.kernel.org
Cc: Magnus Hagander <magnus@hagander.net>
Subject: [PATCH] Allow gitweb tab width to be set per project.
Date: Mon, 18 Oct 2010 12:41:04 +0200 [thread overview]
Message-ID: <1287398464-22721-1-git-send-email-magnus@hagander.net> (raw)
In-Reply-To: <AANLkTimOxim60=gMNZu3n_AztZR7mPAOzg1NevJA2m+4@mail.gmail.com>
Allow the gitweb.tabwidth option to control how many spaces a tab
gets expanded to.
Signed-off-by: Magnus Hagander <magnus@hagander.net>
---
gitweb/README | 4 ++++
gitweb/gitweb.perl | 6 +++++-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/gitweb/README b/gitweb/README
index bf3664f..d2e4a1d 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -312,6 +312,10 @@ You can use the following files in repository:
repository's owner. It is displayed in the project list and summary
page. If it's not set, filesystem directory's owner is used
(via GECOS field / real name field from getpwiud(3)).
+ * gitweb.tabwidth
+ You can use the gitweb.tabwidth repository configuration variable to set
+ the number of spaces that tabs should be expanded to, instead of the
+ default 8.
* various gitweb.* config variables (in config)
Read description of %feature hash for detailed list, and some
descriptions.
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 8d7e4c5..66c258f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1478,9 +1478,13 @@ sub unquote {
# escape tabs (convert tabs to spaces)
sub untabify {
my $line = shift;
+ # git_get_project_config caches the value for us, so it's ok
+ # to call it once for each line.
+ my $tabwidth = git_get_project_config('tabwidth', '--int');
+ $tabwidth = 8 if (!defined $tabwidth || $tabwidth <= 0);
while ((my $pos = index($line, "\t")) != -1) {
- if (my $count = (8 - ($pos % 8))) {
+ if (my $count = ($tabwidth - ($pos % $tabwidth))) {
my $spaces = ' ' x $count;
$line =~ s/\t/$spaces/;
}
--
1.7.0.4
prev parent reply other threads:[~2010-10-18 10:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-28 11:35 [PATCH] Allow gitweb tab width to be set per project Magnus Hagander
2010-09-28 12:25 ` Jakub Narebski
2010-09-29 8:39 ` Magnus Hagander
2010-09-29 9:22 ` Jakub Narebski
2010-10-01 11:56 ` Magnus Hagander
2010-10-01 21:02 ` Jakub Narebski
2010-10-18 10:31 ` Magnus Hagander
2010-10-18 10:41 ` Magnus Hagander [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1287398464-22721-1-git-send-email-magnus@hagander.net \
--to=magnus@hagander.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).