summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-11-16 11:50:23 +0000
committerDouwe Maan <douwe@gitlab.com>2017-11-16 11:50:23 +0000
commit6ca24bd2e196ba3509d52b167bf7592c0afa2793 (patch)
treef41c8dc64a0cf8d19fd366f9ff1484683c109f2a /lib
parenta1ddfbfbdbc9dd6dc67ace574d456ed63f0e52aa (diff)
parent52bfd064627c6a63b82bc81e7ebabac299b25eed (diff)
downloadgitlab-ce-6ca24bd2e196ba3509d52b167bf7592c0afa2793.tar.gz
Merge branch 'fix/git-env-repo-paths' into 'master'
Use relative git object paths to construct absolute ones before setting Env See merge request gitlab-org/gitlab-ce!15376
Diffstat (limited to 'lib')
-rw-r--r--lib/api/helpers/internal_helpers.rb12
-rw-r--r--lib/api/internal.rb4
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb
index 4c0db4d42b1..4b3c473b0bb 100644
--- a/lib/api/helpers/internal_helpers.rb
+++ b/lib/api/helpers/internal_helpers.rb
@@ -36,6 +36,18 @@ module API
{}
end
+ def fix_git_env_repository_paths(env, repository_path)
+ if obj_dir_relative = env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence
+ env['GIT_OBJECT_DIRECTORY'] = File.join(repository_path, obj_dir_relative)
+ end
+
+ if alt_obj_dirs_relative = env['GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'].presence
+ env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_obj_dirs_relative.map { |dir| File.join(repository_path, dir) }
+ end
+
+ env
+ end
+
def log_user_activity(actor)
commands = Gitlab::GitAccess::DOWNLOAD_COMMANDS
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 6e78ac2c903..451121a4cea 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -19,7 +19,9 @@ module API
status 200
# Stores some Git-specific env thread-safely
- Gitlab::Git::Env.set(parse_env)
+ env = parse_env
+ env = fix_git_env_repository_paths(env, repository_path) if project
+ Gitlab::Git::Env.set(env)
actor =
if params[:key_id]