Skip to content

Commit a97e13f

Browse files
Merge pull request #6798 from gojimmypi/autogen-update-wsl-pr
no WSL/Windows git hooks from autogen.sh
2 parents 60f30e9 + d5b6aa3 commit a97e13f

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

autogen.sh

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,44 @@
33
# Create configure and makefile stuff...
44
#
55

6+
# Check environment
7+
if [ -n "$WSL_DISTRO_NAME" ]; then
8+
# we found a non-blank WSL environment distro name
9+
current_path="$(pwd)"
10+
pattern="/mnt/?"
11+
if [ "$(echo "$current_path" | grep -E "^$pattern")" ]; then
12+
# if we are in WSL and shared Windows file system, 'ln' does not work.
13+
no_links=true
14+
else
15+
no_links=
16+
fi
17+
fi
18+
619
# Git hooks should come before autoreconf.
720
if [ -d .git ]; then
821
if [ ! -d .git/hooks ]; then
922
mkdir .git/hooks || exit $?
1023
fi
11-
if [ ! -e .git/hooks/pre-commit ]; then
12-
ln -s ../../pre-commit.sh .git/hooks/pre-commit || exit $?
13-
fi
14-
if [ ! -e .git/hooks/pre-push ]; then
15-
ln -s ../../pre-push.sh .git/hooks/pre-push || exit $?
24+
25+
if [ -n "$no_links" ]; then
26+
echo "Linux ln does not work on shared Windows file system in WSL."
27+
if [ ! -e .git/hooks/pre-commit ]; then
28+
echo "The pre-commit.sh file will not be copied to .git/hooks/pre-commit"
29+
# shell scripts do not work on Windows; TODO create equivalent batch file
30+
# cp ./pre-commit.sh .git/hooks/pre-commit || exit $?
31+
fi
32+
if [ ! -e .git/hooks/pre-push ]; then
33+
echo "The pre-push.sh file will not be copied to .git/hooks/pre-commit"
34+
# shell scripts do not work on Windows; TODO create equivalent batch file
35+
# cp ./pre-push.sh .git/hooks/pre-push || exit $?
36+
fi
37+
else
38+
if [ ! -e .git/hooks/pre-commit ]; then
39+
ln -s ../../pre-commit.sh .git/hooks/pre-commit || exit $?
40+
fi
41+
if [ ! -e .git/hooks/pre-push ]; then
42+
ln -s ../../pre-push.sh .git/hooks/pre-push || exit $?
43+
fi
1644
fi
1745
fi
1846

0 commit comments

Comments
 (0)