summaryrefslogtreecommitdiff
path: root/Documentation/gitweb.conf.txt
blob: b284953f64374e680cd571af0694e9ae6e7c89ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
gitweb.conf(5)
==============

NAME
----
gitweb.conf - Gitweb (Git web interface) configuration file

SYNOPSIS
--------
/etc/gitweb.conf, /etc/gitweb-common.conf, $GITWEBDIR/gitweb_config.perl

DESCRIPTION
-----------

The gitweb CGI script for viewing Git repositories over the web uses a
perl script fragment as its configuration file.  You can set variables
using "`our $variable = value`"; text from a "#" character until the
end of a line is ignored.  See *perlsyn*(1) for details.

An example:

------------------------------------------------
# gitweb configuration file for http://git.example.org
#
our $projectroot = "/srv/git"; # FHS recommendation
our $site_name = 'Example.org >> Repos';
------------------------------------------------


The configuration file is used to override the default settings that
were built into gitweb at the time the 'gitweb.cgi' script was generated.

While one could just alter the configuration settings in the gitweb
CGI itself, those changes would be lost upon upgrade.  Configuration
settings might also be placed into a file in the same directory as the
CGI script with the default name 'gitweb_config.perl' -- allowing
one to have multiple gitweb instances with different configurations by
the use of symlinks.

Note that some configuration can be controlled on per-repository rather than
gitweb-wide basis: see "Per-repository gitweb configuration" subsection on
linkgit:gitweb[1] manpage.


DISCUSSION
----------
Gitweb reads configuration data from the following sources in the
following order:

 * built-in values (some set during build stage),

 * common system-wide configuration file (defaults to
   '/etc/gitweb-common.conf'),

 * either per-instance configuration file (defaults to 'gitweb_config.perl'
   in the same directory as the installed gitweb), or if it does not exists
   then fallback system-wide configuration file (defaults to '/etc/gitweb.conf').

Values obtained in later configuration files override values obtained earlier
in the above sequence.

Locations of the common system-wide configuration file, the fallback
system-wide configuration file and the per-instance configuration file
are defined at compile time using build-time Makefile configuration
variables, respectively `GITWEB_CONFIG_COMMON`, `GITWEB_CONFIG_SYSTEM`
and `GITWEB_CONFIG`.

You can also override locations of gitweb configuration files during
runtime by setting the following environment variables:
`GITWEB_CONFIG_COMMON`, `GITWEB_CONFIG_SYSTEM` and `GITWEB_CONFIG`
to a non-empty value.


The syntax of the configuration files is that of Perl, since these files are
handled by sourcing them as fragments of Perl code (the language that
gitweb itself is written in). Variables are typically set using the
`our` qualifier (as in "`our $variable = <value>;`") to avoid syntax
errors if a new version of gitweb no longer uses a variable and therefore
stops declaring it.

You can include other configuration file using read_config_file()
subroutine.  For example, one might want to put gitweb configuration
related to access control for viewing repositories via Gitolite (one
of Git repository management tools) in a separate file, e.g. in
'/etc/gitweb-gitolite.conf'.  To include it, put

--------------------------------------------------
read_config_file("/etc/gitweb-gitolite.conf");
--------------------------------------------------

somewhere in gitweb configuration file used, e.g. in per-installation
gitweb configuration file.  Note that read_config_file() checks itself
that the file it reads exists, and does nothing if it is not found.
It also handles errors in included file.


The default configuration with no configuration file at all may work
perfectly well for some installations.  Still, a configuration file is
useful for customizing or tweaking the behavior of gitweb in many ways, and
some optional features will not be present unless explicitly enabled using
the configurable `%features` variable (see also "Configuring gitweb
features" section below).


CONFIGURATION VARIABLES
-----------------------
Some configuration variables have their default values (embedded in the CGI
script) set during building gitweb -- if that is the case, this fact is put
in their description.  See gitweb's 'INSTALL' file for instructions on building
and installing gitweb.


Location of repositories
~~~~~~~~~~~~~~~~~~~~~~~~
The configuration variables described below control how gitweb finds
Git repositories, and how repositories are displayed and accessed.

See also "Repositories" and later subsections in linkgit:gitweb[1] manpage.

$projectroot::
	Absolute filesystem path which will be prepended to project path;
	the path to repository is `$projectroot/$project`.  Set to
	`$GITWEB_PROJECTROOT` during installation.  This variable has to be
	set correctly for gitweb to find repositories.
+
For example, if `$projectroot` is set to "/srv/git" by putting the following
in gitweb config file:
+
----------------------------------------------------------------------------
our $projectroot = "/srv/git";
----------------------------------------------------------------------------
+
then
+
------------------------------------------------
http://git.example.com/gitweb.cgi?p=foo/bar.git
------------------------------------------------
+
and its path_info based equivalent
+
------------------------------------------------
http://git.example.com/gitweb.cgi/foo/bar.git
------------------------------------------------
+
will map to the path '/srv/git/foo/bar.git' on the filesystem.

$projects_list::
	Name of a plain text file listing projects, or a name of directory
	to be scanned for projects.
+
Project list files should list one project per line, with each line
having the following format
+
-----------------------------------------------------------------------------
<URI-encoded filesystem path to repository> SP <URI-encoded repository owner>
-----------------------------------------------------------------------------
+
The default value of this variable is determined by the `GITWEB_LIST`
makefile variable at installation time.  If this variable is empty, gitweb
will fall back to scanning the `$projectroot` directory for repositories.

$project_maxdepth::
	If `$projects_list` variable is unset, gitweb will recursively
	scan filesystem for Git repositories.  The `$project_maxdepth`
	is used to limit traversing depth, relative to `$projectroot`
	(starting point); it means that directories which are further
	from `$projectroot` than `$project_maxdepth` will be skipped.
+
It is purely performance optimization, originally intended for MacOS X,
where recursive directory traversal is slow.  Gitweb follows symbolic
links, but it detects cycles, ignoring any duplicate files and directories.
+
The default value of this variable is determined by the build-time
configuration variable `GITWEB_PROJECT_MAXDEPTH`, which defaults to
2007.

$export_ok::
	Show repository only if this file exists (in repository).  Only
	effective if this variable evaluates to true.  Can be set when
	building gitweb by setting `GITWEB_EXPORT_OK`.  This path is
	relative to `GIT_DIR`.  git-daemon[1] uses 'git-daemon-export-ok',
	unless started with `--export-all`.  By default this variable is
	not set, which means that this feature is turned off.

$export_auth_hook::
	Function used to determine which repositories should be shown.
	This subroutine should take one parameter, the full path to
	a project, and if it returns true, that project will be included
	in the projects list and can be accessed through gitweb as long
	as it fulfills the other requirements described by $export_ok,
	$projects_list, and $projects_maxdepth.  Example:
+
----------------------------------------------------------------------------
our $export_auth_hook = sub { return -e "$_[0]/git-daemon-export-ok"; };
----------------------------------------------------------------------------
+
though the above might be done by using `$export_ok` instead
+
----------------------------------------------------------------------------
our $export_ok = "git-daemon-export-ok";
----------------------------------------------------------------------------
+
If not set (default), it means that this feature is disabled.
+
See also more involved example in "Controlling access to Git repositories"
subsection on linkgit:gitweb[1] manpage.

$strict_export::
	Only allow viewing of repositories also shown on the overview page.
	This for example makes `$export_ok` file decide if repository is
	available and not only if it is shown.  If `$projects_list` points to
	file with list of project, only those repositories listed would be
	available for gitweb.  Can be set during building gitweb via
	`GITWEB_STRICT_EXPORT`.  By default this variable is not set, which
	means that you can directly access those repositories that are hidden
	from projects list page (e.g. the are not listed in the $projects_list
	file).


Finding files
~~~~~~~~~~~~~
The following configuration variables tell gitweb where to find files.
The values of these variables are paths on the filesystem.

$GIT::
	Core git executable to use.  By default set to `$GIT_BINDIR/git`, which
	in turn is by default set to `$(bindir)/git`.  If you use Git installed
	from a binary package, you should usually set this to "/usr/bin/git".
	This can just be "git" if your web server has a sensible PATH; from
	security point of view it is better to use absolute path to git binary.
	If you have multiple Git versions installed it can be used to choose
	which one to use.  Must be (correctly) set for gitweb to be able to
	work.

$mimetypes_file::
	File to use for (filename extension based) guessing of MIME types before
	trying '/etc/mime.types'.  *NOTE* that this path, if relative, is taken
	as relative to the current Git repository, not to CGI script.  If unset,
	only '/etc/mime.types' is used (if present on filesystem).  If no mimetypes
	file is found, mimetype guessing based on extension of file is disabled.
	Unset by default.

$highlight_bin::
	Path to the highlight executable to use (it must be the one from
	http://www.andre-simon.de[] due to assumptions about parameters and output).
	By default set to 'highlight'; set it to full path to highlight
	executable if it is not installed on your web server's PATH.
	Note that 'highlight' feature must be set for gitweb to actually
	use syntax highlighting.
+
*NOTE*: for a file to be highlighted, its syntax type must be detected
and that syntax must be supported by "highlight".  The default syntax
detection is minimal, and there are many supported syntax types with no
detection by default.  There are three options for adding syntax
detection.  The first and second priority are `%highlight_basename` and
`%highlight_ext`, which detect based on basename (the full filename, for
example "Makefile") and extension (for example "sh").  The keys of these
hashes are the basename and extension, respectively, and the value for a
given key is the name of the syntax to be passed via `--syntax <syntax>`
to "highlight".  The last priority is the "highlight" configuration of
`Shebang` regular expressions to detect the language based on the first
line in the file, (for example, matching the line "#!/bin/bash").  See
the highlight documentation and the default config at
/etc/highlight/filetypes.conf for more details.
+
For example if repositories you are hosting use "phtml" extension for
PHP files, and you want to have correct syntax-highlighting for those
files, you can add the following to gitweb configuration:
+
---------------------------------------------------------
our %highlight_ext;
$highlight_ext{'phtml'} = 'php';
---------------------------------------------------------


Links and their targets
~~~~~~~~~~~~~~~~~~~~~~~
The configuration variables described below configure some of gitweb links:
their target and their look (text or image), and where to find page
prerequisites (stylesheet, favicon, images, scripts).  Usually they are left
at their default values, with the possible exception of `@stylesheets`
variable.

@stylesheets::
	List of URIs of stylesheets (relative to the base URI of a page). You
	might specify more than one stylesheet, for example to use "gitweb.css"
	as base with site specific modifications in a separate stylesheet
	to make it easier to upgrade gitweb.  For example, you can add
	a `site` stylesheet by putting
+
----------------------------------------------------------------------------
push @stylesheets, "gitweb-site.css";
----------------------------------------------------------------------------
+
in the gitweb config file.  Those values that are relative paths are
relative to base URI of gitweb.
+
This list should contain the URI of gitweb's standard stylesheet.  The default
URI of gitweb stylesheet can be set at build time using the `GITWEB_CSS`
makefile variable.  Its default value is 'static/gitweb.css'
(or 'static/gitweb.min.css' if the `CSSMIN` variable is defined,
i.e. if CSS minifier is used during build).
+
*Note*: there is also a legacy `$stylesheet` configuration variable, which was
used by older gitweb.  If `$stylesheet` variable is defined, only CSS stylesheet
given by this variable is used by gitweb.

$logo::
	Points to the location where you put 'git-logo.png' on your web
	server, or to be more the generic URI of logo, 72x27 size).  This image
	is displayed in the top right corner of each gitweb page and used as
	a logo for the Atom feed.  Relative to the base URI of gitweb (as a path).
	Can be adjusted when building gitweb using `GITWEB_LOGO` variable
	By default set to 'static/git-logo.png'.

$favicon::
	Points to the location where you put 'git-favicon.png' on your web
	server, or to be more the generic URI of favicon, which will be served