Commit 9e6e73de authored by Rémy Coutable's avatar Rémy Coutable

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: default avatarRémy Coutable <remy@rymai.me>
parent 4a27d2a4
---
title: Fix pre-receive hooks when using Git 2.11 or later.
merge_request: 1525
author:
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment