Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Fork.RI and fix Windows short paths usage #126

Merged
merged 5 commits into from
May 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions resources/Fork.RI
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# converted to a windows path.
# Expects the environment variable FORK_RI_EXE_PATH to contain the path to Fork.RI.exe.

UNAME=$(uname -a)
UNAME="$(uname -a)"
# 'uname -a' returns:
# WSL1: Linux PCNAME 4.4.0-17134-Microsoft #706-Microsoft Mon Apr 01 18:13:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
# WSL2: Linux DESKTOP-4P30KCU 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Expand All @@ -13,14 +13,21 @@ UNAME=$(uname -a)

if [[ $UNAME == *icrosoft* ]]; then
# in a wsl shell
WSL_BUILD=$(sed -E 's/^.+-([0-9]+)-Microsoft.*/\1/' <<< $UNAME)
if [ -z $WSL_BUILD ]; then
WSL_BUILD=$(cmd.exe /c "systeminfo" | grep -E -i "build [0-9]+" | sed -E 's/^.*build ([0-9]+).*$/\1/I')
if [ -z "$WSL_BUILD" ]; then
WSL_BUILD=0
fi

if [ $WSL_BUILD -ge 17046 || ! -z $WSL_INTEROP ]; then
if [ $WSL_BUILD -ge 17046 ] || [ -n "$WSL_INTEROP" ]; then
# WSLPATH is available since WSL build 17046

# Make sure that FORK_RI_EXE_PATH does not contain any badly escaped spaces.
# It can happen when using Windows' short paths inside Fork's custom git instance path
# Example: Fork is configured with "C:\Users\SURNAM~1\wslgit\bin\git.exe" instead of "C:\Users\Surname Lastname\wslgit\bin\git.exe"
# which may be a valid use case as is does not support spaces in paths.
# FORK_RI_EXE_PATH would contain "/mnt/c/Users/Surname/ Lastname/wslgit/bin/Fork.RI.exe" before the following sed call
FORK_RI_EXE_PATH="$(sed 's/\/ / /g' <<< "$FORK_RI_EXE_PATH")"

# Make sure that Fork.RI.exe is executable.
chmod +x "$FORK_RI_EXE_PATH"

Expand Down