syntax = "proto3";

package git.v1;

import "common.proto";

// Mirrors: cmd/blame/mod.rs — CommitBlameHunk
message CommitBlameHunk {
  ObjectId commit_oid = 1;
  uint32 final_start_line = 2;
  uint32 final_lines = 3;
  uint32 orig_start_line = 4;
  uint32 orig_lines = 5;
  bool boundary = 6;
  optional string orig_path = 7;
}

// Mirrors: cmd/blame/mod.rs — CommitBlameLine
message CommitBlameLine {
  ObjectId commit_oid = 1;
  uint32 line_no = 2;
  string content = 3;
  optional string orig_path = 4;
}

// Mirrors: cmd/blame/mod.rs — BlameOptions
message BlameOptions {
  optional uint64 min_line = 1;
  optional uint64 max_line = 2;
  bool track_copies_same_file = 3;
  bool track_copies_same_commit_moves = 4;
  bool ignore_whitespace = 5;
}

message BlameFileRequest {
  string repo_id = 1;
  string path = 2;
  optional string rev = 3;
  optional BlameOptions options = 4;
}

message BlameFileResponse {
  repeated CommitBlameHunk hunks = 1;
}

message BlameHunkRequest {
  string repo_id = 1;
  string path = 2;
  optional string rev = 3;
  uint32 start_line = 4;
  uint32 end_line = 5;
}

message BlameHunkResponse {
  repeated CommitBlameHunk hunks = 1;
}

message BlameLinesRequest {
  string repo_id = 1;
  string path = 2;
  optional string rev = 3;
  uint32 start_line = 4;
  uint32 end_line = 5;
}

message BlameLinesResponse {
  repeated CommitBlameLine lines = 1;
}

service BlameService {
  rpc BlameFile(BlameFileRequest) returns (BlameFileResponse);
  rpc BlameStream(BlameFileRequest) returns (stream CommitBlameHunk);
  rpc BlameHunk(BlameHunkRequest) returns (BlameHunkResponse);
  rpc BlameLines(BlameLinesRequest) returns (BlameLinesResponse);
}