git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Allow gitweb tab width to be set per project.
@ 2010-09-28 11:35 Magnus Hagander
  2010-09-28 12:25 ` Jakub Narebski
  0 siblings, 1 reply; 8+ messages in thread
From: Magnus Hagander @ 2010-09-28 11:35 UTC (permalink / raw)
  To: git; +Cc: Magnus Hagander

Allow the gitweb.tabwidth option to control how many spaces a tab
gets expanded to.

Signed-off-by: Magnus Hagander <magnus@hagander.net>
---

In the PostgreSQL project, we're using 4-space tabs, but we have other projects
as well on our gitweb server, so we need to be able to control this on a
per-project basis.


 gitweb/gitweb.perl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a85e2f6..ef92a4f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1465,9 +1465,11 @@ sub unquote {
 # escape tabs (convert tabs to spaces)
 sub untabify {
 	my $line = shift;
+	my $tabwidth = git_get_project_config('tabwidth', '--int');
+	$tabwidth = 8 if ($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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-18 10:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).