syntax = "proto3";

package git.v1;

import "common.proto";

// Mirrors: cmd/merge/mod.rs — MergeAnalysisResult
message MergeAnalysisResult {
  bool is_none = 1;
  bool is_normal = 2;
  bool is_up_to_date = 3;
  bool is_fast_forward = 4;
  bool is_unborn = 5;
}

// Mirrors: cmd/merge/mod.rs — MergePreferenceResult
message MergePreferenceResult {
  bool is_none = 1;
  bool is_no_fast_forward = 2;
  bool is_fastforward_only = 3;
}

// Mirrors: cmd/merge/mod.rs — MergeOptions
message MergeOptions {
  bool find_renames = 1;
  bool fail_on_conflict = 2;
  bool skip_reuc = 3;
  bool no_recursive = 4;
  uint32 rename_threshold = 5;
  uint32 target_limit = 6;
  uint32 recursion_limit = 7;
}

// Mirrors: cmd/merge/merge_commit.rs — MergeCommitParams
message MergeCommitParams {
  ObjectId their_commit = 1;
  CommitSignature author = 2;
  CommitSignature committer = 3;
  string message = 4;
  optional string update_ref = 5;
  optional MergeOptions options = 6;
}

// Mirrors: cmd/merge/merge_tree.rs — MergeTreeResult
message MergeTreeResult {
  ObjectId tree_id = 1;
  bool has_conflicts = 2;
}

// Mirrors: cmd/merge/squash_commit.rs — SquashCommitParams
message SquashCommitParams {
  ObjectId their_commit = 1;
  optional MergeOptions options = 2;
}

message MergeBaseRequest {
  string repo_id = 1;
  ObjectId oid_a = 2;
  ObjectId oid_b = 3;
}

message MergeBaseResponse {
  ObjectId base_oid = 1;
}

message MergeBaseManyRequest {
  string repo_id = 1;
  repeated ObjectId oids = 2;
}

message MergeBaseManyResponse {
  ObjectId base_oid = 1;
}

message MergeBaseOctopusRequest {
  string repo_id = 1;
  repeated ObjectId oids = 2;
}

message MergeBaseOctopusResponse {
  ObjectId base_oid = 1;
}

message MergeAnalysisRequest {
  string repo_id = 1;
  ObjectId oid_a = 2;
  ObjectId oid_b = 3;
}

message MergeAnalysisResponse {
  MergeAnalysisResult analysis = 1;
  MergePreferenceResult preference = 2;
}

message MergeAnalysisForRefRequest {
  string repo_id = 1;
  string ref_name = 2;
  ObjectId oid_a = 3;
  ObjectId oid_b = 4;
}

message MergeAnalysisForRefResponse {
  MergeAnalysisResult analysis = 1;
  MergePreferenceResult preference = 2;
}

message MergeIsConflictedRequest {
  string repo_id = 1;
}

message MergeIsConflictedResponse {
  bool is_conflicted = 1;
}

message MergeheadListRequest {
  string repo_id = 1;
}

message MergeheadListResponse {
  repeated ObjectId oids = 1;
}

message MergeTreeRequest {
  string repo_id = 1;
  ObjectId ours = 2;
  ObjectId theirs = 3;
  optional MergeOptions options = 4;
}

message MergeTreeResponse {
  MergeTreeResult result = 1;
}

message MergeCommitRequest {
  string repo_id = 1;
  MergeCommitParams params = 2;
}

message MergeCommitResponse {
  ObjectId oid = 1;
}

message SquashCommitRequest {
  string repo_id = 1;
  SquashCommitParams params = 2;
}

message SquashCommitResponse {
  ObjectId oid = 1;
}

message MergeAbortRequest {
  string repo_id = 1;
}

message MergeAbortResponse {}

service MergeService {
  rpc MergeBase(MergeBaseRequest) returns (MergeBaseResponse);
  rpc MergeBaseMany(MergeBaseManyRequest) returns (MergeBaseManyResponse);
  rpc MergeBaseOctopus(MergeBaseOctopusRequest) returns (MergeBaseOctopusResponse);
  rpc MergeAnalysis(MergeAnalysisRequest) returns (MergeAnalysisResponse);
  rpc MergeAnalysisForRef(MergeAnalysisForRefRequest) returns (MergeAnalysisForRefResponse);
  rpc MergeIsConflicted(MergeIsConflictedRequest) returns (MergeIsConflictedResponse);
  rpc MergeheadList(MergeheadListRequest) returns (MergeheadListResponse);
  rpc MergeTree(MergeTreeRequest) returns (MergeTreeResponse);
  rpc MergeCommit(MergeCommitRequest) returns (MergeCommitResponse);
  rpc SquashCommit(SquashCommitRequest) returns (SquashCommitResponse);
  rpc MergeAbort(MergeAbortRequest) returns (MergeAbortResponse);
}