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:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-09-26 11:22:20 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-09-26 13:47:59 +0300
commit56310d12306fb818b37539fb104e4701ef0f9b6b (patch)
tree71c9c58f0c711f27a6604a2ae9ac984dc543bd00 /internal/git
parenteaf03c02d1bec230896239f9ab0ac96449fcef1b (diff)
Apply the git.SafeCmd for the Git log wrapper
Closes: https://gitlab.com/gitlab-org/gitaly/issues/1936 Closes: https://gitlab.com/gitlab-org/gitaly/issues/1935
Diffstat (limited to 'internal/git')
-rw-r--r--internal/git/log/last_commit.go37
1 files changed, 12 insertions, 25 deletions
diff --git a/internal/git/log/last_commit.go b/internal/git/log/last_commit.go
index 0d9c4ca8b..76b3c9915 100644
--- a/internal/git/log/last_commit.go
+++ b/internal/git/log/last_commit.go
@@ -4,8 +4,6 @@ import (
"context"
"io/ioutil"
- grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
- log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/internal/command"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/catfile"
@@ -15,7 +13,11 @@ import (
// LastCommitForPath returns the last commit which modified path.
func LastCommitForPath(ctx context.Context, batch *catfile.Batch, repo *gitalypb.Repository, revision string, path string) (*gitalypb.GitCommit, error) {
- cmd, err := git.Command(ctx, repo, "log", "--format=%H", "--max-count=1", revision, "--", path)
+ cmd, err := git.SafeCmd(ctx, repo, nil, git.SubCmd{
+ Name: "log",
+ Flags: []git.Option{git.Flag{"--format=%H"}, git.Flag{"--max-count=1"}},
+ Args: []string{revision},
+ PostSepArgs: []string{path}})
if err != nil {
return nil, err
}
@@ -29,26 +31,11 @@ func LastCommitForPath(ctx context.Context, batch *catfile.Batch, repo *gitalypb
}
// GitLogCommand returns a Command that executes git log with the given the arguments
-func GitLogCommand(ctx context.Context, repo *gitalypb.Repository, revisions []string, paths []string, extraArgs ...string) (*command.Command, error) {
- grpc_logrus.Extract(ctx).WithFields(log.Fields{
- "Revisions": revisions,
- }).Debug("GitLog")
-
- formatFlag := "--pretty=%H"
-
- args := []string{
- "log",
- formatFlag,
- }
- args = append(args, extraArgs...)
- args = append(args, revisions...)
- args = append(args, "--")
- args = append(args, paths...)
-
- cmd, err := git.Command(ctx, repo, args...)
- if err != nil {
- return nil, err
- }
-
- return cmd, nil
+func GitLogCommand(ctx context.Context, repo *gitalypb.Repository, revisions []string, paths []string, extraArgs ...git.Option) (*command.Command, error) {
+ return git.SafeCmd(ctx, repo, nil, git.SubCmd{
+ Name: "log",
+ Flags: append([]git.Option{git.Flag{"--pretty=%H"}}, extraArgs...),
+ Args: revisions,
+ PostSepArgs: paths,
+ })
}