Files
git/builtin-help.c
Steffen Prohaska ee10a9759a Move computation of absolute paths from Makefile to runtime and compute prefix on the fly if RUNTIME_PREFIX set
This is the first commit of a series that adds support for
relocatable binaries (called RUNTIME_PREFIX).  Such binaries can be
moved together with the system configuration files to a different
directory, as long as the relative paths from the binary to the
configuration files stays the same.  This functionality is
essential on Windows where we deliver git binaries with an
installer that allows to freely choose the installation location.
The commit series implements RUNTIME_PREFIX only on Windows.  The
architecture is such that adding support on Unix should not be too
hard.

This first commits makes all paths relative in the Makefile and
teaches system_path() to add the prefix instead.  We used to
compute absolute paths in the Makefile and passed them to C as
defines.  We now pass relative paths to C and call system_path() to
add the prefix at runtime.

If RUNTIME_PREFIX is unset we use the static prefix.  This will be
the default on Unix.  Thus, the behavior is unchanged compared to
the old implementation.

If RUNTIME_PREFIX is set the prefix is computed from the location
of the executable.  In this case, system_path() tries to strip
known directories that executables can be located in from the path
of the executable.  If the path is successfully stripped it is used
as the prefix.  For example, if the executable is
"/msysgit/bin/git" and BINDIR is "bin", then the prefix computed is
"/msysgit".

If the runtime prefix computation fails, we fall back to the static
prefix specified in the makefile.  This can be the case if the
executable is not installed at a known location.  Note that our
test system sets GIT_CONFIG_NOSYSTEM to tell git to ignore global
configuration files during testing.  Hence testing does not trigger
the fall back.

Note that the implementation requires argv0_path to be set to an
absolute path, which is currently the case only on Windows.
argv0_path must point to the directory of the executable.  We use
assert() to verify this during debugging.  On Windows, the wrapper
for main() (see compat/mingw.h) guarantees that this is the case.
On Unix, further work is required before RUNTIME_PREFIX can be
enabled.
2008-12-25 11:52:09 +01:00

11 KiB