[英]Git pre-receive hook newRev issue
在執行前收到鈎git show $newrev
節目中DIFF $newRev
但如果在執行pre-receive
勾我會去回購和執行相同的命令git show $newrev
它會返回錯誤fatal: bad object {newRev}
。
Git 版本:2.22.0。 在 Git 2.7.4 git show
在 repo 中執行git show
不會返回錯誤。
當git show
正常工作時pre-receive hook script
#!/usr/bin/env bash
read oldrev newrev refname
git show $newrev
pre-receive hook script
帶有睡眠的pre-receive hook script
並在 repo 中手動運行git show
#!/usr/bin/env bash
read oldrev newrev refname
sleep 999
cd /repo
git show ae435ae1f9de55620d306cc82799ff20870f4238
致命:壞對象ae435ae1f9de55620d306cc82799ff20870f4238
經過調查,我了解到pre-receive
鈎子中的 Git 創建了單獨的臨時目錄,它收集有關提交的信息。 例如臨時目錄名稱是objects/incoming-GsAsa
。
但是 Git 只在pre-receive
鈎子腳本中知道它,因為它正確設置了GIT_OBJECT_DIRECTORY
和GIT_ALTERNATE_OBJECT_DIRECTORIES
環境。
因此,問題的答案是正確設置GIT_OBJECT_DIRECTORY
和GIT_ALTERNATE_OBJECT_DIRECTORIES
變量。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.