How to run gitweb ?

541 views
Skip to first unread message

Timothy Madden

unread,
May 25, 2012, 10:58:57 AM5/25/12
to msy...@googlegroups.com
Hello

I ran gitweb 1.7.10.msysgit.1 (and git-core binaries 1.7.10.msysgit.1, too)
on Windows 7 Professional SP1 32-bit.

I read on the gitweb page on msysgit wiki that all I need to run gitweb is
to copy the CGI.pm from a perl installation (like ActivePerl) into the msys
perl installed with Git.

But when I try it I find that gitweb needs many more perl modules, some of
which require C compilation and can not be installed in msys perl. So after
a lot of struggle I ended up using cygwin perl, where the modules could be
installed. But then the repository (and other??) paths used by the gitweb
script where no longer the same as the paths used by the git commands
invoked in the script. To deal with that, I just use the "/repositories/git"
directory as the projects root, which:
- in cygwin (and the gitweb script) happens to mean:
D:/Local/cygwin/repositories/git, and
- in plain (native) git command means:
C:/repositories/git

Than I had to make Windows NTFS directory junctions (directory hard links if
you wish), with mklink command and the Administrator account, so that both
directories point to D:/repositories/git.

Somehow I have the feeling this is not the intended or the proper way to run
gitweb. But as you may already know, if I try gitweb with any other
distribution of perl than cygwin or msys, I get the message 'List form of
pipe open not implemented' from the script.

So I am left with only cygwin perl or msys perl to choose from.

Which brings me to the next problem: I feel pretty bad about myself knowing
that I ran gitweb as a CGI, instead of using mod_perl handler in Apache, or
at least run it as a FastCGI, as the online manual page shows.

When trying to run gitweb as a FastCGI server, it first complains about
missing environment variables (GITWEB_CONFIG and HOME). So I provide them
with -initial-env option to the FastCgiServer directive in Apache config.
And now I just get "fastcgi server exited with status '0'" in my Apache
logs, and the script still does not work. No other messages, no logs, so I
do not know what to check for or what to do next. Trying to debug the script
with cygwin perl and with a foreign TTY (since the fast cgi server spawned
by Apache would have no TTY that I could use) or with a remote port got me
nowhere, as cygwin perl quickly segfaults if I use such options in
PERLDBG_OPTS env var.

If I try to use gitweb with mod_perl in Apache, which is what I have been
trying to achieve, I find that there is no mod_perl.so that would work with
my Win32 Apache and cygwin perl. Trying to build it also did not help,
cygwin gcc complains about some declarations in Apache header files.

Is there please a way to get gitweb running with Win32 Apache better than a
CGI with the cygwin-tricks that I had to use ?

Can it please be fixed so as to no longer use the "list form of pipe open",
so I can use it with ActiveState/Indigo/... mod_perl ?

Is there a way to fix the "exited with status '0'" problem when run as a
FastCgi server ?

Thank you,
Timothy Madden

Heiko Voigt

unread,
May 25, 2012, 11:49:51 AM5/25/12
to Timothy Madden, msy...@googlegroups.com
Hi,

On Fri, May 25, 2012 at 05:58:57PM +0300, Timothy Madden wrote:
> I ran gitweb 1.7.10.msysgit.1 (and git-core binaries 1.7.10.msysgit.1, too)
> on Windows 7 Professional SP1 32-bit.
>
> I read on the gitweb page on msysgit wiki that all I need to run gitweb is
> to copy the CGI.pm from a perl installation (like ActivePerl) into the msys
> perl installed with Git.
>
[...]
It can probably be fixed. But it needs someone to work on this, maybe
you? There is a related issue[1] in our github tracker. Maybe you can
work together with the people from there. If need arises we can provide
you with more pointers how you can get your solution integrated into
msysgit.

> Is there a way to fix the "exited with status '0'" problem when run as a
> FastCgi server ?

I do not know anything about this. But maybe the people from the issue
above know some pointers.

Cheers Heiko

[1] https://github.com/msysgit/git/issues/9

Timothy Madden

unread,
May 25, 2012, 6:05:01 PM5/25/12
to msy...@googlegroups.com
Thank you for the answers.

Well for start I am more of a python fellow. No particular reason, just
that it seems to be "en vogue", and it so happens I did not get any perl
project on my hands until now. But I must say, just by trying (pretty
hard) to get Git and gitweb running on a Windows server, I already like
perl ... :) I still find the "my" and "our" declarations funny, though...

Anyway, about the required packages to run gitweb on msys perl, I should
say that I did manage to install them, but I first needed to discover a
forgotten secret named "msys development environment" on the msys wiki
page. It provides some needed POSIX/BSD network functions and headers on
top of windows sockets, as part of what they call "thin POSIX layer"
provided by msys-1.0.dll. Why do they have to be so minimalist and keep
such (widely-used) functions away, instead of including them in MinGW, I
can not understand...

Now, unfortunately, even with msys perl I still ran into the same
problems I had with cygwin perl. That is:

1.) I can not seem to find a good name for the path to my repositories.
gitweb running under msys-perl expects a path beginning with slash /
but such a path in msys-perl is relative to the msys installation
directory, while for the git executable invoked from gitweb the path
is "relative" to the root of the current drive (C:, D:, ...)

2.) The gitweb script as a FastCGI server will exit immediately as if web
server requested the shutdown. I could connect with the debugger, for
both cygwin perl and msys perl, and it looks like the CGI::Fast perl
module really returns 'undef' from the new() method call, to indicate
shutdown request from the web server.

Now I wonder, is there a particular reason why msys perl does not support
threads ? Can I attempt to compile it with -Dusethreads ? A threaded
version is needed in order to later compile mod_perl for Win32 Apache, if
that is possible.

Thank you,
Timothy Madden

Pat Thoyts

unread,
May 26, 2012, 4:26:52 AM5/26/12
to Timothy Madden, msy...@googlegroups.com
On 25 May 2012 23:05, Timothy Madden <termin...@gmail.com> wrote:
>
> Well for start I am more of a python fellow. No particular reason, just
> that it seems to be "en vogue", and it so happens I did not get any perl
> project on my hands until now. But I must say, just by trying (pretty
> hard) to get Git and gitweb running on a Windows server, I already like
> perl ... :) I still find the "my" and "our" declarations funny, though...
>
> Anyway, about the required packages to run gitweb on msys perl, I should
> say that I did manage to install them, but I first needed to discover a
> forgotten secret named "msys development environment" on the msys wiki
> page. It provides some needed POSIX/BSD network functions and headers on
> top of windows sockets, as part of what they call "thin POSIX layer"
> provided by msys-1.0.dll. Why do they have to be so minimalist and keep
> such (widely-used) functions away, instead of including them in MinGW, I
> can not understand...

Well found. Yes - the perl we bundle with msysGit is an msys perl - that
is it is built to use the msys unix emulating environment and this affects
all path related functions.

> Now, unfortunately, even with msys perl I still ran into the same
> problems I had with cygwin perl. That is:
>
> 1.) I can not seem to find a good name for the path to my repositories.
>    gitweb running under msys-perl expects a path beginning with slash /
>    but such a path in msys-perl is relative to the msys installation
>    directory, while for the git executable invoked from gitweb the path
>    is "relative" to the root of the current drive (C:, D:, ...)

Use /c/ as an equivalent to C:\. eg:
$ perl -MCwd -e "chdir('/c/src'); print glob('/c/W*');"
/c/Windows

Ciaran

unread,
May 26, 2012, 5:05:56 AM5/26/12
to Pat Thoyts, Timothy Madden, msy...@googlegroups.com
FWIW I've got a working instaweb done in issue #11 do you need to run git web separately or could you get away with using instaweb, if the latter then I would appreciate help with #11 :)

(I've submitted a separate pull request to add the missing peel module (CGI) to the msysgit & wingit bundles, but I've not yet had feedback on it, to know of I'm tackling that problem correctly :) )

- cj

Timothy Madden

unread,
May 27, 2012, 11:43:26 PM5/27/12
to msy...@googlegroups.com
On 05/26/2012 12:05 PM, Ciaran wrote:
>
>
> On Saturday, May 26, 2012, Pat Thoyts wrote:
>
> On 25 May 2012 23:05, Timothy Madden <termin...@gmail.com
I saw the instaweb part, great job !
But I am new to all this and I do not know how instaweb is related to
FastCGI or mod_perl, which is what I am trying to achieve. I see you are
happy to run instaweb with plain old CGI.

I tried to start a patch to get gitweb running with ActivePerl, and I
quickly ran into the problem of guessing the appropriate quoting for the
Windows command shell cmd.exe. This is what I found until now:

1. The appropriate quoting is not exactly documented. I do not have an
official source for this statement, but unofficial ones say so and I
actually could not find such documentation. If you know of such
documentation please let me know. Until then, I had to read Microsoft VC
run-time library source code to figure things out.

2. Under Windows each application is responsible for splitting the
command line into words and populating argv, from a single plain text
string holding the command line as entered by the user, including any
existing quoting. This may not be obvious to the programmer since it is
done by the C run-time library before main() is entered, but that is the
rule on Windows.

3. The command shell (cmd.exe) still has to scan the command line though
to expand environment variable names, to find I/O redirections with >
and <, to find multiple-statement operators like |, ||, & and &&, and to
find statement groups with ( and ).

4. Since there are now two applications parsing the command line, it is
very well possible for the two to parse it differently and get different
meanings for it ! Fortunately the first of the two apps, the command
shell, does not really care about the meaning of the command line arguments.

5. The application usually parses the command with the MS VC++ runtime
library (msvcrt##.dll), which uses the following rules:
1. arguments are sparated by space or tab characters, unless they
are quoted
2. at any point in the command line you can start quoting with a
double-quote character, and end quoting with a matching
double-quote character.
3. If you want a literal double-quote, precede it with a blackslash.
4. if you don't want a literal double-quote, but you want a literal
backslash before the quote, use a double backslash. If you want
a double backslash before the quote, make sure to double them
both ...
5. if you want a literal backslash and a literal double quote,
prefix each of them with a backslash. Again, if you want more
backslashes instead of one, than double each of them.
6. The same rules for a literal quote apply inside quoted arguments,
but there a quote can also be represented as a pair of quote
characters.

6. The command shell has different rules: it will look the the shell
special characters (|, &, <, >) anywhere in the line that is past an
even number of quotes (including 0 such quotes), and it will ignore
special characters anywhere that is past an odd number of quotes on the
command line. Any backslashes are ignored.

However I see that not all applications follow the msvcrt rules. For
example MinGW g++ and Windows ftp will see
" word word2""" word3"
as a single argument, while msvcrt says there are two arguments there,
and I am not sure why this is happening. Cygiwn rm, Win32 python27 and a
windows batch file (.cmd) will see the correct number of words there.

However Windows .cmd files, including git on Windows, do not see any
backslashes as escapes for double-quotes on the command line.

It is all such a mess. Do you have more information about this ?

I need to properly quote Windows command lines, in order to convert
"List form of pipe open" to "string form" in gitweb.cgi.

Thank you,
Timothy Madden

Timothy Madden

unread,
May 31, 2012, 6:52:43 AM5/31/12
to msy...@googlegroups.com
On Mon, 28 May 2012 06:43:26 +0300, Timothy Madden wrote:

[...]
> I saw the instaweb part, great job !
> But I am new to all this and I do not know how instaweb is related to
> FastCGI or mod_perl, which is what I am trying to achieve. I see you are
> happy to run instaweb with plain old CGI.
>
> I tried to start a patch to get gitweb running with ActivePerl, and I
> quickly ran into the problem of guessing the appropriate quoting for the
> Windows command shell cmd.exe. This is what I found until now:
[...]
> It is all such a mess. Do you have more information about this ?
>
> I need to properly quote Windows command lines, in order to convert
> "List form of pipe open" to "string form" in gitweb.cgi.

Ok I found some documentation about command line parsing with the MS C
run-time in MSDN (just look for "Parsing C++ Command-Line arguments",
currently the MSDN link is at http://msdn.microsoft.com/en-us/library/
windows/desktop/17w5ykft%28v=vs.85%29.aspx) and I decided to use that to
quote command line arguments.

Which is a good thing, but it says nothing about parsing in cmd.exe, and
it does not work with Windows command shell (cmd.exe) batch files.
Remember msys git also provides a git.cmd script to be placed on PATH.
And now I am wondering if it is at all needed, that is if some argument
to git.exe will ever contain a literal double-quote or % character.

Also I would like to know how does bash.exe under MinGW/Msys quotes
arguments for the command line of a child windows process internally.

Timothy Madden

Reply all
Reply to author
Forward
0 new messages