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-11-07 11:38:45 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-11-07 11:38:45 +0300
commit10afb93e11fb2214aee2edb9143861e179dc0fe9 (patch)
tree2aa942397c97255a97f8e18fd838f6c2fa59b8cb
parentc339f6274584361df5cdb572cfcc8de1f06fd80e (diff)
Use the GitDSL for raw diffs
The Git DSL makes it harder to inject commands into Gitaly, and we're applying it to all RPCs as part of an [Epic](https://gitlab.com/groups/gitlab-org/-/epics/1893). Closes https://gitlab.com/gitlab-org/gitaly/issues/1962
-rw-r--r--internal/service/diff/raw.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/internal/service/diff/raw.go b/internal/service/diff/raw.go
index 24c5678f1..a65ac53cc 100644
--- a/internal/service/diff/raw.go
+++ b/internal/service/diff/raw.go
@@ -16,13 +16,17 @@ func (s *server) RawDiff(in *gitalypb.RawDiffRequest, stream gitalypb.DiffServic
return status.Errorf(codes.InvalidArgument, "RawDiff: %v", err)
}
- cmdArgs := []string{"diff", "--full-index", in.LeftCommitId, in.RightCommitId}
+ subCmd := git.SubCmd{
+ Name: "diff",
+ Flags: []git.Option{git.Flag{"--full-index"}},
+ Args: []string{in.LeftCommitId, in.RightCommitId},
+ }
sw := streamio.NewWriter(func(p []byte) error {
return stream.Send(&gitalypb.RawDiffResponse{Data: p})
})
- return sendRawOutput(stream.Context(), "RawDiff", in.Repository, sw, cmdArgs)
+ return sendRawOutput(stream.Context(), "RawDiff", in.Repository, sw, subCmd)
}
func (s *server) RawPatch(in *gitalypb.RawPatchRequest, stream gitalypb.DiffService_RawPatchServer) error {
@@ -30,17 +34,21 @@ func (s *server) RawPatch(in *gitalypb.RawPatchRequest, stream gitalypb.DiffServ
return status.Errorf(codes.InvalidArgument, "RawPatch: %v", err)
}
- cmdArgs := []string{"format-patch", "--stdout", in.LeftCommitId + ".." + in.RightCommitId}
+ subCmd := git.SubCmd{
+ Name: "format-patch",
+ Flags: []git.Option{git.Flag{"--stdout"}},
+ Args: []string{in.LeftCommitId + ".." + in.RightCommitId},
+ }
sw := streamio.NewWriter(func(p []byte) error {
return stream.Send(&gitalypb.RawPatchResponse{Data: p})
})
- return sendRawOutput(stream.Context(), "RawPatch", in.Repository, sw, cmdArgs)
+ return sendRawOutput(stream.Context(), "RawPatch", in.Repository, sw, subCmd)
}
-func sendRawOutput(ctx context.Context, rpc string, repo *gitalypb.Repository, sender io.Writer, cmdArgs []string) error {
- cmd, err := git.Command(ctx, repo, cmdArgs...)
+func sendRawOutput(ctx context.Context, rpc string, repo *gitalypb.Repository, sender io.Writer, subCmd git.SubCmd) error {
+ cmd, err := git.SafeCmd(ctx, repo, nil, subCmd)
if err != nil {
if _, ok := status.FromError(err); ok {
return err