每当我尝试使用预提交钩子在当前分支名称前添加前缀时,都会生成sh.exe.stackdump文件,并且该钩子不起作用。我尝试了许多其他已验证可以在其他PC上运行的文件,这使我认为这与钩子本身无关。
我在Windows 10上使用git 2.18。我已经验证了我的PATH是否正确,已经重新安装了git,并且除了Windows Defender之外没有任何AV正在运行。
Stackdump:
Exception: STATUS_STACK_OVERFLOW at rip=7FFE4951EC07
rax=0000000000000010 rbx=0000000000000000 rcx=0000000000000010
rdx=000000000000000C rsi=00000000FFFFAA50 rdi=00007FFE3CA8B600
r8 =00000000FFFFA988 r9 =00000000FFFFA9C0 r10=00000000FFFFA000
r11=00000000FFE03EA0 r12=FFFFFFFFFFFFFFFF r13=00000000FFFFADC0
r14=000000000000014C r15=0000000000000000
rbp=00000000FFFFA9C0 rsp=00000000FFFFA978
program=C:\Program Files\Git\usr\bin\sh.exe, pid 17444, thread
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
000FFFFA9C0 7FFE4951EC07 (00000000104, 000FFFFAA38, 7FFE494FFE58, 00000000000)
000FFFFA9C0 7FFE494FD827 (7FFE3CA8B600, 7FFE3CA8B600, 00000000001, 00000230022)
000FFFFAA38 7FFE45B48A24 (7FFE49480000, 7FFE494FD7A0, 7FFE494E7AC0, 7FFFFFFEFFFF)
000FFFFAC00 7FFE45B488A1 (5E03000600010000, 5A4E5B7BB435, 000FFFFAAC0, 000FFFFADC0)
000FFFFAC00 7FFE45B48704 (7FFE3CA8B810, FFFFFFFFFFFFFFFF, 0000084E840, 7FFE3CA8B810)
000FFFFAC00 7FFE3C9F11A0 (000FFFFAC00, 0000084E840, 00000000190, 00000000000)
000FFFFAC00 7FFE3C9C4DCC (7FFE00000005, 7FFE3C9C4C10, 00000160000, 000007E4D80)
000FFFFB3D0 7FFE3C99F83E (4F004E004F0043, 02400540055, 00000000000, 00180010018)
000007E4D80 7FFE3C99EA38 (000000001D4, 000FFFFBA00, 000FFFFB760, 000FFFFB7F8)
000FFFFB760 7FFE3C9973EC (000FFFFB8D0, 000000001DC, 00000000000, 0018028E980)
000000001D4 7FFE45B58966 (00000000001, 00000000000, 0018022F490, 00000000001)
000000001D4 7FFE4882A103 (00000000020, 00000000000, 000FFFFBB20, 00000000001)
000000001D4 001800AB2B5 (000FFFFBAC0, 0018028E980, 00000000001, 00000000001)
000FFFFBD30 001800ABFF5 (00100410FBB, 001803213B0, 0060004E980, 001004E9740)
000FFFFBD30 0018011DE4B (00100410FBB, 001803213B0, 0060004E980, 001004E9740)
000FFFFBD30 00000FAE458 (00100410FBB, 001803213B0, 0060004E980, 001004E9740)
End of stack trace (more stack frames may be present)
我尝试过的prepare-commit-msg文件之一:
#!/bin/sh
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
BRANCH_NAME=$(echo "$BRANCH_NAME" | sed -E 's/([0-9]+-[0-9]+)-.*/\1/')
echo Prepending branch name $BRANCH_NAME
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "$BRANCH_NAME" $1)
if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
sed -i.bak -e "1s/^/$BRANCH_NAME /" $1
fi
答案 0 :(得分:0)
我已经验证了我的PATH是否正确
仍然:要进行测试,请在C:\ Git中解压缩PortableGit-2.18.0-64-bit.7z.exe
,并使用简化的PATH(在CMD中仅用于测试)
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\Git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%MAVEN_HOME%\bin;%PATH%
然后,在该CMD中,使用该钩子再次尝试在存储库中进行提交。