Fix pre-receive hooks when using Git 2.11 or later
Starting with Git 2.11:
* In order for the receiving end of "git push" to inspect the
received history and decide to reject the push, the objects sent
from the sending end need to be made available to the hook and
the mechanism for the connectivity check, and this was done
traditionally by storing the objects in the receiving repository
and letting "git gc" expire them. Instead, store the newly
received objects in a temporary area, and make them available by
reusing the alternate object store mechanism to them only while we
decide if we accept the check, and once we decide, either migrate
them to the repository or purge them immediately.
This means that some special environment variables
(`GIT_OBJECT_DIRECTORY`, and `GIT_ALTERNATE_OBJECT_DIRECTORIES`) need to be
set (or passed to `Rugged::Repository.new` in the `alternates` keyword
argument) in order for the new-and-no-yet-accepted objects to be
seen by the various Git commands (e.g. `rev-list` or
`Gitlab::Git::Commit#find`).
Signed-off-by:
Rémy Coutable <remy@rymai.me>
Showing
Please register or sign in to comment