Skip to main content
The DiffService provides methods for computing differences between commits, including patches, deltas, and statistics.

CommitDiff

Returns a stream of commit diffs with patches chunked over messages.

Request

repository
Repository
required
The repository to retrieve diffs from
left_commit_id
string
required
The commit ID to compare from (base)
right_commit_id
string
required
The commit ID to compare to (head)
ignore_whitespace_change
bool
Whether to ignore whitespace changes in the diff
paths
bytes[]
Optional list of paths to limit the diff to specific files
collapse_diffs
bool
Whether to collapse large diffs
enforce_limits
bool
Whether to enforce max_files, max_lines, and max_bytes limits
max_files
int32
Maximum number of files to include (only enforced when enforce_limits is true)
max_lines
int32
Maximum number of lines to include (only enforced when enforce_limits is true)
max_bytes
int32
Maximum number of bytes to include (only enforced when enforce_limits is true)
max_patch_bytes
int32
Limitation of a single diff patch. Patches surpassing this limit are pruned. If set to 0, empty patches are returned.
safe_max_files
int32
Safe maximum files limit (only enforced when collapse_diffs is true)
safe_max_lines
int32
Safe maximum lines limit (only enforced when collapse_diffs is true)
safe_max_bytes
int32
Safe maximum bytes limit (only enforced when collapse_diffs is true)
diff_mode
DiffMode
The mode for generating diffs. Values: DEFAULT (linewise diff for text files), WORDDIFF (word-level diff for whitespace-separated words)

Response (Stream)

from_path
bytes
Original file path
to_path
bytes
New file path
from_id
string
Blob ID of the original file (from git diff —full-index)
to_id
string
Blob ID of the new file (from git diff —full-index)
old_mode
int32
File mode of the original file
new_mode
int32
File mode of the new file
binary
bool
Whether the file is binary
raw_patch_data
bytes
The raw patch data for this chunk
end_of_patch
bool
Indicates the end of the patch for this file
overflow_marker
bool
Indicates the diff overflowed according to the specified limitations. Only this attribute will be set when true.
collapsed
bool
Indicates the patch surpassed a safe limit and was pruned, but can be requested in full on a separate request
too_large
bool
Indicates the patch was pruned due to exceeding a hard limit and cannot be expanded

CommitDelta

Returns a stream of deltas between commits (file changes without patch data).

Request

repository
Repository
required
The repository to retrieve deltas from
left_commit_id
string
required
The commit ID to compare from
right_commit_id
string
required
The commit ID to compare to
paths
bytes[]
Optional list of paths to limit the delta to specific files

Response (Stream)

deltas
CommitDelta[]
Array of commit deltas

CommitDelta

from_path
bytes
Original file path
to_path
bytes
New file path
from_id
string
Blob ID of the original file
to_id
string
Blob ID of the new file
old_mode
int32
File mode of the original file
new_mode
int32
File mode of the new file

RawDiff

Returns the raw diff output as a stream.

Request

repository
Repository
required
The repository to retrieve the raw diff from
left_commit_id
string
required
The commit ID to compare from
right_commit_id
string
required
The commit ID to compare to

Response (Stream)

data
bytes
Chunk of raw diff data

RawPatch

Returns the raw patch output as a stream.

Request

repository
Repository
required
The repository to retrieve the raw patch from
left_commit_id
string
required
The commit ID to compare from
right_commit_id
string
required
The commit ID to compare to

Response (Stream)

data
bytes
Chunk of raw patch data

DiffStats

Returns statistics about changes between commits.

Request

repository
Repository
required
The repository to retrieve diff statistics from
left_commit_id
string
required
The commit ID to compare from
right_commit_id
string
required
The commit ID to compare to

Response (Stream)

stats
DiffStats[]
Array of diff statistics for changed files

DiffStats

path
bytes
File path
additions
int32
Number of lines added
deletions
int32
Number of lines deleted
old_path
bytes
Original file path (for renamed files)

FindChangedPaths

Returns a list of files that have been changed in the given commits. Each commit is compared to its parent. Merge commits show files that are different to all of their parents.

Request

repository
Repository
required
The repository to search for changed paths
commits
string[]
required
List of commit IDs to find changed paths for

Response (Stream)

paths
ChangedPaths[]
Array of changed paths with their status

ChangedPaths

path
bytes
File path that was changed
status
Status
Type of change. Values: ADDED, MODIFIED, DELETED, TYPE_CHANGE, COPIED

Build docs developers (and LLMs) love