【问题标题】:Git pre-receive hook newRev issueGit pre-receive hook newRev 问题
【发布时间】:2019-07-16 10:56:12
【问题描述】:

在执行预接收钩子git show $newrev 时在$newRev 中显示差异,但如果在执行pre-receive 钩子时我将去repo 并执行相同的命令git show $newrev,它将返回错误fatal: bad object {newRev}

Git 版本:2.22.0。在 Git 2.7.4 上,在 repo 中执行 git show 不会返回错误。

pre-receive hook scriptgit show 正常工作时

#!/usr/bin/env bash
read oldrev newrev refname

git show $newrev

pre-receive hook script 休眠并在 repo 中手动运行git show

#!/usr/bin/env bash
read oldrev newrev refname

sleep 999
cd /repo
git show ae435ae1f9de55620d306cc82799ff20870f4238

致命:坏对象 ae435ae1f9de55620d306cc82799ff20870f4238

【问题讨论】:

    标签: git githooks


    【解决方案1】:

    经过调查,我了解到 pre-receive 钩子中的 Git 创建了单独的临时目录,在其中收集有关提交的信息。例如临时目录名称是objects/incoming-GsAsa

    但 Git 只在 pre-receive 钩子脚本中知道它,因为它正确设置了 GIT_OBJECT_DIRECTORYGIT_ALTERNATE_OBJECT_DIRECTORIES 环境。

    所以,问题的答案是正确设置GIT_OBJECT_DIRECTORYGIT_ALTERNATE_OBJECT_DIRECTORIES vars。

    【讨论】:

      猜你喜欢
      • 2013-10-17
      • 2012-08-16
      • 2017-01-18
      • 1970-01-01
      • 2016-09-19
      • 1970-01-01
      • 2015-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多