Skip to content

Commit

Permalink
portable: ship with all .dll files copied from bin -> libexec/git-core
Browse files Browse the repository at this point in the history
When installing .exe files into a different directory than their .dll
dependencies, there is always a chance that a mismatching version of
the same .dll in C:\WINDOWS\system32 is used.

For that reason, we already have a post install script in place that
tries to hardlink all .dll files from the bin directory into the
libexec/git-core directory, falling back to copying them.

However, this only works if the portable Git was installed using the
self-extracting installer that executes that post install script, or
if Git Bash was started at least once, or if the post install script
was executed manually.

We should do better than this: start with copied versions, and try to
hard-link in the post install script if possible.

This addresses git-for-windows/git#1086

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Mar 19, 2017
1 parent 0d5b01f commit 160ccbd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions portable/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ LIST="$(ARCH=$ARCH BITNESS=$BITNESS \
grep -v "^mingw$BITNESS/etc/gitconfig$")" ||
die "Could not generate file list"

rm -rf "$SCRIPT_PATH/root/mingw$BITNESS/libexec/git-core" &&
mkdir -p "$SCRIPT_PATH/root/mingw$BITNESS/libexec/git-core" &&
ln $(echo "$LIST" | sed -n "s|^mingw$BITNESS/bin/[^/]*\.dll$|/&|p") \
"$SCRIPT_PATH/root/mingw$BITNESS/libexec/git-core/" ||
die "Could not copy .dll files into libexec/git-core/"

# 7-Zip will strip absolute paths completely... therefore, we can add another
# root directory like this:

Expand Down
18 changes: 10 additions & 8 deletions portable/root/etc/post-install/13-copy-dlls.post
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
ln_or_cp () {
ln "$@" ||
cp "$@" ||
echo "ERROR: could not link $*" >&2
}

hardlink_all_dlls () {
exec_path="$(git --exec-path)" ||
return

test ! -e "$exec_path/dlls-copied" ||
return

prefix_path="${exec_path%libexec/git-core}"
ln "$prefix_path/bin/git.exe" "$exec_path/dlls-copied" || {
touch "$exec_path/dlls-copied"
return
}

if test "a$prefix_path" != "a$exec_path"
then
for dll in "$prefix_path"bin/*.dll
do
test -f "$exec_path"/${dll##*/} ||
ln_or_cp "$dll" "$exec_path"
ln -f "$dll" "$exec_path" ||
echo "ERROR: could not link $dll $exec_path" >&2
done
fi
}
Expand Down

0 comments on commit 160ccbd

Please sign in to comment.