Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2017-10-05 17:41:17 +0300
committerAhmad Sherif <me@ahmadsherif.com>2017-10-10 17:22:53 +0300
commit322b283e8a38e6ee6f09ac622dd37126cb87b38c (patch)
treecce59bb0a0948f1a5cedadea6a73b64d1bcb3a56
parenta692612feba73638721aea2e02c0e2ae58710496 (diff)
Use relative paths for git object dir attributes
Related to #629
-rw-r--r--CHANGELOG.md5
-rw-r--r--internal/git/command.go12
-rw-r--r--internal/service/commit/find_all_commits_test.go10
-rw-r--r--internal/service/commit/isancestor_test.go10
4 files changed, 26 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a6f09a6c..b498e63cc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Gitaly changelog
+UNRELEASED
+
+- Use relative paths for git object dir attributes
+ https://gitlab.com/gitlab-org/gitaly/merge_requests/393
+
v0.45.1
- Implement OperationService::UserMergeBranch
diff --git a/internal/git/command.go b/internal/git/command.go
index 043a0c5b5..256bed223 100644
--- a/internal/git/command.go
+++ b/internal/git/command.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os/exec"
+ "path"
"strings"
"gitlab.com/gitlab-org/gitaly/internal/command"
@@ -22,12 +23,17 @@ func Command(ctx context.Context, repo *pb.Repository, args ...string) (*command
var env []string
if dir := repo.GetGitObjectDirectory(); dir != "" {
- env = append(env, fmt.Sprintf("GIT_OBJECT_DIRECTORY=%s", dir))
+ env = append(env, fmt.Sprintf("GIT_OBJECT_DIRECTORY=%s", path.Join(repoPath, dir)))
}
if dirs := repo.GetGitAlternateObjectDirectories(); len(dirs) > 0 {
- dirsList := strings.Join(dirs, ":")
- env = append(env, fmt.Sprintf("GIT_ALTERNATE_OBJECT_DIRECTORIES=%s", dirsList))
+ var dirsList []string
+
+ for _, dir := range dirs {
+ dirsList = append(dirsList, path.Join(repoPath, dir))
+ }
+
+ env = append(env, fmt.Sprintf("GIT_ALTERNATE_OBJECT_DIRECTORIES=%s", strings.Join(dirsList, ":")))
}
return command.New(ctx, exec.Command(command.GitPath(), args...), nil, nil, nil, env...)
diff --git a/internal/service/commit/find_all_commits_test.go b/internal/service/commit/find_all_commits_test.go
index 9994061f1..c0b9f248f 100644
--- a/internal/service/commit/find_all_commits_test.go
+++ b/internal/service/commit/find_all_commits_test.go
@@ -283,8 +283,10 @@ func TestSuccessfulFindAllCommitsRequestWithAltGitObjectDirs(t *testing.T) {
storagePath := testhelper.GitlabTestStoragePath()
testRepoPath := path.Join(storagePath, testRepo.RelativePath)
- testRepoCopyPath := path.Join(storagePath, "is-ancestor-alt-test-repo")
- altObjectsPath := path.Join(testRepoCopyPath, ".git/alt-objects")
+ testRepoCopyName := "find-all-commits-alt-test-repo"
+ testRepoCopyPath := path.Join(storagePath, testRepoCopyName)
+ altObjectsDir := "./alt-objects"
+ altObjectsPath := path.Join(testRepoCopyPath, ".git", altObjectsDir)
gitObjectEnv := []string{
fmt.Sprintf("GIT_OBJECT_DIRECTORY=%s", altObjectsPath),
fmt.Sprintf("GIT_ALTERNATE_OBJECT_DIRECTORIES=%s", path.Join(testRepoCopyPath, ".git/objects")),
@@ -321,7 +323,7 @@ func TestSuccessfulFindAllCommitsRequestWithAltGitObjectDirs(t *testing.T) {
}{
{
desc: "present GIT_ALTERNATE_OBJECT_DIRECTORIES",
- altDirs: []string{altObjectsPath},
+ altDirs: []string{altObjectsDir},
expectedCount: 1,
},
{
@@ -337,7 +339,7 @@ func TestSuccessfulFindAllCommitsRequestWithAltGitObjectDirs(t *testing.T) {
request := &pb.FindAllCommitsRequest{
Repository: &pb.Repository{
StorageName: testRepo.StorageName,
- RelativePath: testRepo.RelativePath,
+ RelativePath: path.Join(testRepoCopyName, ".git"),
GitAlternateObjectDirectories: testCase.altDirs,
},
Revision: currentHead,
diff --git a/internal/service/commit/isancestor_test.go b/internal/service/commit/isancestor_test.go
index 3cbab4502..46e468a95 100644
--- a/internal/service/commit/isancestor_test.go
+++ b/internal/service/commit/isancestor_test.go
@@ -186,8 +186,10 @@ func TestSuccessfulIsAncestorRequestWithAltGitObjectDirs(t *testing.T) {
storagePath := testhelper.GitlabTestStoragePath()
testRepoPath := path.Join(storagePath, testRepo.RelativePath)
- testRepoCopyPath := path.Join(storagePath, "is-ancestor-alt-test-repo")
- altObjectsPath := path.Join(testRepoCopyPath, ".git/alt-objects")
+ testRepoCopyName := "is-ancestor-alt-test-repo"
+ testRepoCopyPath := path.Join(storagePath, testRepoCopyName)
+ altObjectsDir := "./alt-objects"
+ altObjectsPath := path.Join(testRepoCopyPath, ".git", altObjectsDir)
gitObjectEnv := []string{
fmt.Sprintf("GIT_OBJECT_DIRECTORY=%s", altObjectsPath),
fmt.Sprintf("GIT_ALTERNATE_OBJECT_DIRECTORIES=%s", path.Join(testRepoCopyPath, ".git/objects")),
@@ -226,7 +228,7 @@ func TestSuccessfulIsAncestorRequestWithAltGitObjectDirs(t *testing.T) {
}{
{
desc: "present GIT_ALTERNATE_OBJECT_DIRECTORIES",
- altDirs: []string{altObjectsPath},
+ altDirs: []string{altObjectsDir},
result: true,
},
{
@@ -241,7 +243,7 @@ func TestSuccessfulIsAncestorRequestWithAltGitObjectDirs(t *testing.T) {
request := &pb.CommitIsAncestorRequest{
Repository: &pb.Repository{
StorageName: testRepo.StorageName,
- RelativePath: testRepo.RelativePath,
+ RelativePath: path.Join(testRepoCopyName, ".git"),
GitAlternateObjectDirectories: testCase.altDirs,
},
AncestorId: string(previousHead),