gitwebによるブラウザでのgitリポジトリ閲覧 - end0tknr's kipple - web写経開発
以前の上記entryでは、oracle linux上のapache httpd でしたので、今回は iis for win。
step1 - gitweb.cgi の入手
windows環境に installしている git には、linux版と異なり、gitweb.cgi がありません。 source から buildするのも手間ですので、今回は oracle linux にある
$ tree /var/www/git/
/var/www/git/
|-- gitweb.cgi
`-- static
|-- git-favicon.png
|-- git-logo.png
|-- gitweb.css
`-- gitweb.js
を「c:/inetpub/wwwroot/gitweb/ 」へ コピーしました。
step2 - iis の ハンドラーマッピング追加
windows11のiisによるperl cgiの動作 - end0tknr's kipple - web写経開発 を参考に以下

step3 - c:/inetpub/wwwroot/gitweb/gitweb.conf 作成
$projectroot の設定は必須で、それ以外は後日
#### refer to https://git-scm.com/docs/gitweb.conf
$projectroot = "c:/inetpub/wwwroot/git/git";
$feature{'snapshot'}{'default'} = [ 'zip' ];
#$javascript = "/html/git/static/gitweb.js";
#push(@stylesheets,"/html/git/static/custom.css");
#$stylesheet = "/html/git/static/gitweb.css";
#$home_link_str = "HOME";
#$site_header = "/home/end0tknr/local/html/git/header.html";
#$site_footer = "/home/end0tknr/local/html/git/footer.html";
iisが、この設定ファイルを読むようシステム環境変数に以下を設定
GITWEB_CONFIG = c:\inetpub\wwwroot\gitweb\gitweb.conf
step4 - gitweb.cgi の改造
gitweb.cgi は、元々 linux 用ですので、動作するよう少々、改造します。
# 83行目 - gitコマンドの場所
old) our $GIT = "/usr/bin/git";
new) our $GIT = "git";
# 3879行目 - win環境は getpwuid()がない為
return ""; ## ADD
my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
# win環境は Fcntl::AUTOLOADに対応していない為
# 2010行目
return '----------'; ## ADD
if (S_ISGITLINK($mode)) {
# 2033行目
return "unknown"; ## ADD
if ($mode !~ m/^[0-7]+$/) {
# 2057行目
return "unknown"; ## ADD
if ($mode !~ m/^[0-7]+$/) {
# 4765行目
old) if (S_ISLNK(oct $t->{'mode'})) {
new) if (0) {