syntax = "proto3";

package gitaly;

import "lint.proto";
import "shared.proto";

option go_package = "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb";

// SmartHTTPService is a service that provides RPCs required for HTTP-based Git
// clones via the smart HTTP protocol.
service SmartHTTPService {
  // The response body for GET /info/refs?service=git-upload-pack
  // Will be invoked when the user executes a `git fetch`, meaning the server
  // will upload the packs to that user. The user doesn't upload new objects.
  rpc InfoRefsUploadPack(InfoRefsRequest) returns (stream InfoRefsResponse) {
    option (op_type) = {
      op: ACCESSOR
    };
  }

  // The response body for GET /info/refs?service=git-receive-pack
  // Will be invoked when the user executes a `git push`, but only advertises
  // references to the user.
  rpc InfoRefsReceivePack(InfoRefsRequest) returns (stream InfoRefsResponse) {
    option (op_type) = {
      op: ACCESSOR
    };
  }

  // Request and response body for POST /upload-pack using sidechannel protocol
  rpc PostUploadPackWithSidechannel(PostUploadPackWithSidechannelRequest) returns (PostUploadPackWithSidechannelResponse) {
    option (op_type) = {
      op: ACCESSOR
    };
  }

  // Request and response body for POST /receive-pack
  rpc PostReceivePack(stream PostReceivePackRequest) returns (stream PostReceivePackResponse) {
    option (op_type) = {
      op: MUTATOR
    };
  }
}

// This comment is left unintentionally blank.
message InfoRefsRequest {
  // This comment is left unintentionally blank.
  Repository repository = 1 [(target_repository)=true];
  // Parameters to use with git -c (key=value pairs)
  repeated string git_config_options = 2;

  // Git protocol version
  string git_protocol = 3;
}

// This comment is left unintentionally blank.
message InfoRefsResponse {
  // This comment is left unintentionally blank.
  bytes data = 1;
}

// This comment is left unintentionally blank.
message PostUploadPackWithSidechannelRequest {
  // repository should only be present in the first message of the stream
  Repository repository = 1 [(target_repository)=true];
  // Parameters to use with git -c (key=value pairs)
  repeated string git_config_options = 2;
  // Git protocol version
  string git_protocol = 3;
}

// This comment is left unintentionally blank.
message PostUploadPackWithSidechannelResponse {
}

// This comment is left unintentionally blank.
message PostReceivePackRequest {
  // repository should only be present in the first message of the stream
  Repository repository = 1 [(target_repository)=true];
  // Raw data to be copied to stdin of 'git receive-pack'
  bytes data = 2;
  // gl_id, gl_repository, and gl_username become env variables, used by the Git {pre,post}-receive
  // hooks. They should only be present in the first message of the stream.
  string gl_id = 3;
  // This comment is left unintentionally blank.
  string gl_repository = 4;
  // This comment is left unintentionally blank.
  string gl_username = 5;
  // Git protocol version
  string git_protocol = 6;

  // Parameters to use with git -c (key=value pairs)
  repeated string git_config_options = 7;
}

// This comment is left unintentionally blank.
message PostReceivePackResponse {
  // Raw data from stdout of 'git receive-pack'
  bytes data = 1;
}
