> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mesa.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# diffs.get()

> Inspect the diff between two changes.

Retrieve a structured diff between two Mesa change IDs.

**Required scope: `read`**

```python theme={null}
diff = await mesa.diffs.get(
    repo="app",
    base_change_id="zyxwvutsrqponmlkzyxwvutsrqponmlk",
    head_change_id="lmnopqrstuvwzyxklmnopqrstuvwzyxk",
)

print(diff.stats.additions, diff.stats.deletions)
```

Fetch only conflicted entries:

```python theme={null}
diff = await mesa.diffs.get(
    repo="app",
    base_change_id="zyxwvutsrqponmlkzyxwvutsrqponmlk",
    head_change_id="lmnopqrstuvwzyxklmnopqrstuvwzyxk",
    conflicts="only",
)
```

## Options

<ParamField path="repo" type="str" required>
  Repository name.
</ParamField>

<ParamField path="base_change_id" type="str" required>
  Base Mesa change ID.
</ParamField>

<ParamField path="head_change_id" type="str" required>
  Head Mesa change ID.
</ParamField>

<ParamField path="conflicts" type="'include' | 'only' | 'exclude' | None">
  Controls whether conflicted entries are included, excluded, or returned exclusively.
</ParamField>

<ParamField path="org" type="str | None">
  Organization override.
</ParamField>

## Response

`entries[]` and `conflicted_entries[]` are mutually exclusive: unresolved conflicted paths appear only in `conflicted_entries[]`.

<ResponseField name="base_change_id" type="str">
  Base change used for comparison.
</ResponseField>

<ResponseField name="head_change_id" type="str">
  Head change used for comparison.
</ResponseField>

<ResponseField name="stats" type="DiffStats">
  Aggregate counts for the response.
</ResponseField>

<ResponseField name="truncated" type="bool">
  Whether the response hit the server entry limit and is incomplete.
</ResponseField>

<ResponseField name="entries" type="list[DiffEntry]">
  Structural changed entries. Unchanged paths are omitted.
</ResponseField>

<ResponseField name="conflicted_entries" type="list[ConflictedDiffEntry]">
  Conflict-only details for unresolved paths.
</ResponseField>

### DiffStats

<ResponseField name="entries" type="int">
  Number of structural entries returned in `entries[]`.
</ResponseField>

<ResponseField name="additions" type="int">
  Total added lines across textual diff hunks.
</ResponseField>

<ResponseField name="deletions" type="int">
  Total deleted lines across textual diff hunks.
</ResponseField>

<ResponseField name="changes" type="int">
  Sum of `additions` and `deletions`.
</ResponseField>

<ResponseField name="conflicted_entries" type="int">
  Number of paths returned in `conflicted_entries[]`.
</ResponseField>

<ResponseField name="conflicted_hunks" type="int">
  Total conflict hunk count across `conflicted_entries[]`.
</ResponseField>

### DiffEntry

<ResponseField name="path" type="str">
  Repository-relative path at the head change.
</ResponseField>

<ResponseField name="status" type="'added' | 'modified' | 'deleted' | 'renamed'">
  How the entry changed between the base and head changes.
</ResponseField>

<ResponseField name="old_path" type="str | None">
  Previous repository-relative path for renamed entries. Null for non-renames.
</ResponseField>

<ResponseField name="size_bytes" type="int | None">
  Approximate size in bytes of the changed entry content, not the textual diff.
</ResponseField>

<ResponseField name="is_conflicted" type="bool">
  Always false for entries returned in `entries[]`. Conflicted paths are returned in `conflicted_entries[]`.
</ResponseField>

<ResponseField name="omitted_reason" type="'binary' | 'too_large' | 'file_limit' | None">
  Why textual hunk data is unavailable. Null when `hunks` is present.
</ResponseField>

<ResponseField name="hunks" type="list[DiffHunk] | None">
  Structured textual diff hunks. Null when `omitted_reason` is set.
</ResponseField>

<ResponseField name="conflict_hunks" type="list[DiffConflictHunk] | None">
  Structured conflict hunks for the entry, or null when there are none. Structural entries in `entries[]` normally return null.
</ResponseField>

### DiffHunk

<ResponseField name="old_start" type="int">
  Starting line number in the base side.
</ResponseField>

<ResponseField name="old_lines" type="int">
  Number of base-side lines covered by the hunk.
</ResponseField>

<ResponseField name="new_start" type="int">
  Starting line number in the head side.
</ResponseField>

<ResponseField name="new_lines" type="int">
  Number of head-side lines covered by the hunk.
</ResponseField>

<ResponseField name="lines" type="list[DiffLine]">
  Lines in this textual diff hunk.
</ResponseField>

### DiffLine

<ResponseField name="kind" type="'context' | 'added' | 'deleted' | 'annotation'">
  Line classification inside a textual diff hunk.
</ResponseField>

<ResponseField name="text" type="str">
  Line text.
</ResponseField>

### ConflictedDiffEntry

<ResponseField name="path" type="str">
  Repository-relative path for the unresolved conflict.
</ResponseField>

<ResponseField name="hunks" type="list[DiffConflictHunk]">
  Per-hunk conflict detail. Empty when `omitted_reason` is set or the conflict is non-textual.
</ResponseField>

<ResponseField name="size_bytes" type="int | None">
  Approximate size in bytes of the largest side of the conflict.
</ResponseField>

<ResponseField name="omitted_reason" type="'binary' | 'too_large' | None">
  Why hunk data is unavailable. When set, fetch file bytes with `mesa.content.get()` against the target or source change to compose a whole-file resolution.
</ResponseField>

### DiffConflictHunk

<ResponseField name="hunk_id" type="str">
  Stable identifier for the conflict hunk.
</ResponseField>

<ResponseField name="old_start" type="int">
  Starting line number in the base side.
</ResponseField>

<ResponseField name="old_lines" type="int">
  Number of base-side lines covered by the hunk.
</ResponseField>

<ResponseField name="new_start" type="int">
  Starting line number in the head side.
</ResponseField>

<ResponseField name="new_lines" type="int">
  Number of head-side lines covered by the hunk.
</ResponseField>

<ResponseField name="target" type="ChangeConflictHunkSide | None">
  Target side of the conflicted hunk.
</ResponseField>

<ResponseField name="base" type="ChangeConflictHunkSide | None">
  Base side of the conflicted hunk.
</ResponseField>

<ResponseField name="source" type="ChangeConflictHunkSide | None">
  Source side of the conflicted hunk.
</ResponseField>

### ChangeConflictHunkSide

<ResponseField name="content" type="str">
  Base64-encoded raw bytes for this side of the conflicted hunk.
</ResponseField>
