syntax = "proto3";

package mesh.v1;

import "mesh/v1/git_model.proto";
import "mesh/v1/git_plumbing.proto";
import "mesh/v1/stream.proto";

option go_package = "atlassian.com/bitbucket/mesh/rpc/v1";
option java_multiple_files = true;
option java_outer_classname = "GitPorcelainProtos";
option java_package = "com.atlassian.bitbucket.mesh.rpc.v1";

/* Enumerates the possible modes for archive format detection in git archive */
enum RpcArchiveFormat {
  ARCHIVE_FORMAT_UNSPECIFIED = 0;
  ARCHIVE_FORMAT_TAR = 1;
  ARCHIVE_FORMAT_TAR_GZ = 2;
  ARCHIVE_FORMAT_TGZ = 3;
  ARCHIVE_FORMAT_ZIP = 4;
}

/* Request for git archive */
message RpcArchiveRequest {
  string repository = 1;
  RpcGitOptions options = 2;
  RpcGitTimeouts timeouts = 3;

  RpcArchiveFormat format = 4;
  repeated bytes paths = 5;
  string prefix = 6;
  bytes rev = 7;
}

message RpcBlameRequest {
  string repository = 1;
  RpcGitOptions options = 2;
  RpcGitTimeouts timeouts = 3;

  bytes path = 10;
  bytes rev = 11;
  RpcBlameType type = 12;
  RpcBlameRange range = 13;
}

message RpcBlameRange {
  int32 start = 1;

  oneof end_or_offset {
    int32 end = 2;
    int32 offset = 3;
  }
}

enum RpcBlameType {
  INCREMENTAL = 0;
  PORCELAIN = 1;
}

/* Enumerates the possible modes for the --color flag in git diff */
enum RpcDiffColor {
  COLOR_UNSPECIFIED = 0;
  COLOR_ALWAYS = 1;
  COLOR_AUTO = 2;
  COLOR_NEVER = 3;
}

/* Reusable options that are common to git diff requests */
message RpcDiffOptions {
  RpcDiffColor color = 1;
  optional int32 context_lines = 2;
  optional string dst_prefix = 3;
  RpcDiffRenames renames = 4;
  optional int32 rename_threshold = 5;
  optional string src_prefix = 6;
  RpcDiffWhitespace whitespace = 7;
}

/* Enumerates the possible reusable output modes for diff, diff-tree and log */
enum RpcDiffOutput {
  OUTPUT_UNSPECIFIED = 0;
  OUTPUT_CHECK = 1;
  OUTPUT_DEFAULT = 2;
  OUTPUT_NAME_ONLY = 3;
  OUTPUT_NAME_STATUS = 4;
  OUTPUT_PATCH = 5;
  OUTPUT_SUPPRESS = 6;
}

/* Enumerates the possible modes for rename detection in git diff */
enum RpcDiffRenames {
  RENAMES_UNSPECIFIED = 0;
  RENAMES_OFF = 1;
  RENAMES_COPIES = 2;
  RENAMES_MORE_COPIES = 3;
  RENAMES_ON = 4;
}

/* Request for git diff */
message RpcDiffRequest {
  string repository = 1;
  RpcGitOptions options = 2;
  RpcGitTimeouts timeouts = 3;

  bytes rev = 10;
  bytes ancestor = 11;
  repeated bytes paths = 12;

  RpcDiffOptions diff_options = 20;
}

/* Request for git diff-tree */
message RpcDiffTreeRequest {
  string repository = 1;
  RpcGitOptions options = 2;
  RpcGitTimeouts timeouts = 3;

  bool always = 10;
  bytes ancestor = 11;
  string format = 12;
  bool merges = 13;
  repeated bytes paths = 14;
  bool recursive = 15;
  bytes rev = 16;
  bool root = 17;

  RpcDiffOptions diff_options = 20;
}

/* Request for git diff-tree --stdin */
message RpcDiffTreeStdinFragment {
  oneof request_oneof {
    RpcDiffTreeRequest request = 1;
    RpcStreamChunk stdin = 2;
  }
}

/* Enumerates the possible modes for whitespace detection in git diff */
enum RpcDiffWhitespace {
  WHITESPACE_UNSPECIFIED = 0;
  WHITESPACE_SHOW = 1;
  WHITESPACE_IGNORE_ALL = 2;
}

message RpcFormatPatchRequest {
  string repository = 1;
  RpcGitOptions options = 2;
  RpcGitTimeouts timeouts = 3;

  oneof ancestors {
    bool all_ancestors = 4;
    bytes ancestor = 5;
  }

  bytes rev = 6;
}

/* Request for git log */
message RpcLogRequest {
  string repository = 1;
  RpcGitOptions options = 2;
  RpcGitTimeouts timeouts = 3;

  RpcDiffOutput diff_output = 10;
  bool follow = 11;
  RpcRevListOptions log_options = 12;
}

/* Request for git log --stdin. */
message RpcLogStdinFragment {
  oneof request_oneof {
    RpcLogRequest request = 1;
    RpcStreamChunk stdin = 2;
  }
}
