git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Allow gitweb tab width to be set per project.

From
Magnus Hagander <magnus@hagander.net>
Date
Oct 18, 2010, 10:41 UTC
Message-ID
<1287398464-22721-1-git-send-email-magnus@hagander.net>
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
Previous: Magnus Hagander
Message 8 of 8 in “Allow gitweb tab width to be set per project.”
  1. Allow gitweb tab width to be set per project.Magnus Hagander, Sep 28, 2010
  2. Jakub NarebskiSep 28, 2010
  3. Magnus HaganderSep 29, 2010
  4. Jakub NarebskiSep 29, 2010
  5. Magnus HaganderOct 1, 2010
  6. Jakub NarebskiOct 1, 2010
  7. Magnus HaganderOct 18, 2010
  8. Allow gitweb tab width to be set per project.Magnus Hagander, Oct 18, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.