Skip to content

Fix pre-receive hooks not working with symlinked paths

John Cai requested to merge jc-simplify-git-object-dir-handling into master

fixes: gitlab#223839 (closed)

Currently the way GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES gets passed from git -> gitaly-hooks -> pre receive RPC -> gitlab api is overly complex.

This MR passes those two env vars without modifying them through via the EnvironmentVariables field in the PreReceiveHookRequest protobuf message.

Then the PreReceiveHook RPC handler will pass these straight through to the ruby pre-receive hook, or in the case of the go implementation it will relativize the path but it will first call EvalSymlink on the repo path before doing so.

This matches the current way things work in object_dirs_helper.rb where repo_path = Dir.pwd evals the symlink and gets the real path.

Note that in the case there is a symlink in the path, git will eval this to a real path (albeit not a cleaned real path).

Edited by John Cai

Merge request reports