syntax = "proto3";

package gitaly;

import "shared.proto";

service SmartHTTPService {
  // The response body for GET /info/refs?service=git-upload-pack
  rpc InfoRefsUploadPack(InfoRefsRequest) returns (stream InfoRefsResponse) {}

  // The response body for GET /info/refs?service=git-receive-pack
  rpc InfoRefsReceivePack(InfoRefsRequest) returns (stream InfoRefsResponse) {}

  // Request and response body for POST /upload-pack
  rpc PostUploadPack(stream PostUploadPackRequest) returns (stream PostUploadPackResponse) {}

  // Request and response body for POST /receive-pack
  rpc PostReceivePack(stream PostReceivePackRequest) returns (stream PostReceivePackResponse) {}
}

message InfoRefsRequest {
  Repository repository = 1;
}

message InfoRefsResponse {
  bytes data = 1;
}

message PostUploadPackRequest {
  // repository should only be present in the first message of the stream
  Repository repository = 1;
  // Raw data to be copied to stdin of 'git upload-pack'
  bytes data = 2;
}

message PostUploadPackResponse {
  // Raw data from stdout of 'git upload-pack'
  bytes data = 1;
}

message PostReceivePackRequest {
  // repository should only be present in the first message of the stream
  Repository repository = 1;
  // Raw data to be copied to stdin of 'git receive-pack'
  bytes data = 2;
  // gl_id and gl_repository becomes 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;
  string gl_repository = 4;
}

message PostReceivePackResponse {
  // Raw data from stdout of 'git receive-pack'
  bytes data = 1;
}
