Skip to content

Enhancement: skip gitweb from Git for Windows #1362

@dscho

Description

@dscho

Git for Windows is intended to be used by end users. GitWeb, however, wants to be used in conjunction with a web server such as Apache, and even requires a Perl module to be installed in that web server.

It is almost guaranteed that nobody uses Git for Windows that way, so let's just exclude those files from the installer.

How to get started with this?

As always, install a Git for Windows SDK.

This will take a while, so please plan ahead and do something else while it is installing the SDK (it will download something like 200+ megabytes and unpack everything into a neat directory structure).

It will open a Git SDK Bash, and leave it open for you to use. The same Git SDK Bash is also installed as a Desktop shortcut automatically.

Build a portable Git (to verify that you can)

The idea of building a portable Git (as opposed to a Git for Windows installer) is that you will want to compare the output with and without your new patches. But the installer allows only one installation, not side-by-side installations. The portable Git, however, does allow that.

In the Git SDK Bash, switch the current working directory to /usr/src/build-extra. This is the worktree of the repository that has all the scripts to orchestrate the release engineering, including how to build an installer.

Run ./portable/release.sh 0-test. This will create a new portable Git "installer" in your home directory, called PortableGit-0-test-64-bit.7z.exe (or ...-32-bit... if you do this with a 32-bit Git for Windows SDK).

The portable Git installer is actually a self-extracting 7-Zip archive that simply runs one very simple .bat script to initialize certain files and directories required by the MSYS2 system Git uses to execute Unix shell scripts.

You can execute this file and choose a location where Git should be extracted. Let's do this right away, and perform a brief test to verify that it worked: simply execute git-bash.exe in the extracted top-level directory.

Exclude the gitweb files

Identify the files

First of all, let's identify the gitweb files. To that end, we use the fact that the Git for Windows SDK is actually a slightly modified MSYS2 setup, with a proper package management system called "Pacman". This allows us to "install" software into the SDK (which internally simply means that an archive is unpacked, and for some packages a simple shell script is executed afterwards).

Git itself is maintained as one of those Pacman packages, called mingw-w64-x86_64-git package (or if you are using a 32-bit SDK, mingw-w64-i686-git).

In the Git for Windows SDK, you can see the list of files included in this package using the following command:

pacman -Ql mingw-w64-x86_64-git | less

(| less simply means that the output of the pacman command is not printed directly, but fed to the program "less" which lets you scroll forwards and backwards, and most importantly: search).

To find the files related to gitweb, let's use less' search capabilities. First of all, switch off case-sensitivity, just in case, by pressing -iEnter. Then, press the forward slash key (/), then type in gitweb and then press Enter. This will skip to the first line containing that string and highlight it. To get to the next matching line, hit n. To jump back to the previous match, hit Shift+n.

Actually exclude the files

The script that is used by ./portable/release.sh to generate the list of files to include in the 7-Zip archive is called make-file-list.sh, and lives directly in /usr/src/build-extra/.

This make-file-list.sh script already contains tons of exclusions , e.g. the plain .txt versions of the help pages, or git-cvsserver.

We will have to imitate, say, git-cvsserver's exclusions to also exclude the gitweb files.

Instead of excluding them one by one (which would add a huge list to the make-file-list.sh script), we should use a pattern. The way make-file-list.sh excludes files is to use grep, and this program allows specifying patterns as regular expressions. No need to worry, though, we will use only very rudimentary regular expressions of the form ^/mingw../.*/gitweb/, where the ^ anchors the pattern to the start of the line, a single . means any character, and .* means any number of any characters (i.e. a variable-length string of pretty much anything).

This pattern, ^/mingw../.*/gitweb/ should already catch most of the gitweb files identified in the previous step, you probably have to add one or more patterns to catch them all.

Now, simply copy-edit the line that excludes the git-cvsserver script, once for every pattern.

Test the new portable Git

Simply generate a new portable Git, say, by executing ./portable/release.sh 1-test, and run it to extract a new portable Git.

Now, verify first of all that git-bash.exe of that new portable still runs fine.

After that, compare the files in the two portable Gits that you generated, by any directory tree comparer you like. If you like bare-bones command-line, you could do this, for example:

find /path/to/first/portable/git >with-gitweb.txt
find/path/to/second/portable/git >without-gitweb.txt
git diff --no-index with-gitweb.txt without-gitweb.txt

Wrap your work in a neat Pull Request

Once you verified that it all works as extended, and that the correct files are excluded,

  1. commit your work in /usr/src/build-extra. (Please do not forget to sign off on your work, and also please spend a few minutes to write a nice commit message explaining the rationale, probably just copy-editing the first paragraph(s) of this ticket.)
  2. Then, create a fork of https://github.com/git-for-windows/build-extra (unless you already have one).
  3. Push your commits to your fork.
  4. Direct your browser to https://github.com/git-for-windows/build-extra; after a couple of seconds, it should offer you to open a new Pull Request from the just-pushed branch.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions