Description: Ensure compatibility with git 2.11 by setting env variables
Author: Rémy Coutable <remy@rymai.me>
Applied-Upstream: https://gitlab.com/gitlab-org/gitlab-shell/merge_requests/120/
Last-Update: 2017-02-07
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v3.6.7
+  - Send (a selection of) git environment variables while making the API call to `/allowed`, !112
+
 v3.6.6
   - Re-use the default logger when logging metrics data
 
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.6.6
+3.6.7
--- a/lib/gitlab_access.rb
+++ b/lib/gitlab_access.rb
@@ -21,7 +21,12 @@
   end
 
   def exec
-    status = api.check_access('git-receive-pack', @repo_name, @actor, @changes, @protocol)
+    env = {
+      "GIT_ALTERNATE_OBJECT_DIRECTORIES" => ENV["GIT_ALTERNATE_OBJECT_DIRECTORIES"],
+      "GIT_OBJECT_DIRECTORY" => ENV["GIT_OBJECT_DIRECTORY"]
+    }
+
+    status = api.check_access('git-receive-pack', @repo_name, @actor, @changes, @protocol, env: env.to_json)
 
     raise AccessDeniedError, status.message unless status.allowed?
 
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -15,14 +15,15 @@
   CHECK_TIMEOUT = 5
   READ_TIMEOUT = 300
 
-  def check_access(cmd, repo, actor, changes, protocol)
+  def check_access(cmd, repo, actor, changes, protocol, env: {})
     changes = changes.join("\n") unless changes.kind_of?(String)
 
     params = {
       action: cmd,
       changes: changes,
       project: project_name(repo),
-      protocol: protocol
+      protocol: protocol,
+      env: env
     }
 
     if actor =~ /\Akey\-\d+\Z/
