git.commits.file-diff

Read one file's diff in a commit, in pages of rows

GET /git/api/repositories/{repoId}/commits/{sha}/files/diffIAM git:PullRepositoryReadSensitive read, audited

Paged: a large change is read a page of files and a page of rows at a time, never as one payload. A file with more than 1,500 changed lines, or a lock file or build output, has `collapsed` set (the console folds it until asked); a file whose patch is over 16 MiB answers `state: too-large`. Lines longer than 10,000 characters are cut, with the number left out in `cut`.

Request syntax

GET /git/api/repositories/{repoId}/commits/{sha}/files/diff

Path parameters

  • repoIdRequired

    string

    Constraints: uuid

  • shaRequired

    string

    Constraints: 1-255 chars

Query parameters

  • pathRequired

    string

    The file, as the file list names it

    Constraints: 1-4096 chars

  • oldPathOptional

    string

    A renamed file's `oldPath` from the file list, so the rename is followed

    Constraints: 1-4096 chars

  • offsetOptional

    number

    `nextOffset` of the previous page; the first row when absent

    Constraints: integer, min 0

  • limitOptional

    number

    Rows per page, at most 5000; 1000 when absent

    Constraints: integer, 1-5000

  • layoutOptional

    enum

    `unified` (the default) one row per line; `split` old and new side by side

    One of: unified, split

  • highlightOptional

    enum

    `true` to add syntax-highlighted HTML to each line; false when absent

    One of: true, false

  • ignoreWhitespaceOptional

    enum

    `true` to leave out changes that only touch whitespace; false when absent

    One of: true, false

  • baseOptional

    string

    The `base` commit the file list answered with: pass both so every page describes the same change if a branch moves meanwhile; the current one when absent

    Constraints: /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/

  • headOptional

    string

    The `head` commit the file list answered with: pass both so every page describes the same change if a branch moves meanwhile; the current one when absent

    Constraints: /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/

Response

200 with `state`, `rows`, `totalRows`, `nextOffset` and `hunks`. 404 for an unknown commit.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Fields of data

  • pathAlways

    string

    The file, as asked for
  • oldPathAlways

    string, may be null

    Where a renamed file came from; null otherwise
  • statusAlways

    one of added, modified, deleted, renamed

    What the change did to the file
  • binaryAlways

    boolean

    A binary file: no rows
  • layoutAlways

    one of unified, split

    `split` pairs old and new lines side by side
  • stateAlways

    one of ok, binary, too-large, no-changes, missing

    `ok` with rows; `binary`; `too-large` (the patch is over 16 MiB); `no-changes` (a pure rename or a mode change, or only whitespace when it is ignored); `missing` (the path is not part of this change)
  • totalRowsAlways

    number

    Rows the file has in this layout, hunk headers included
  • offsetAlways

    number

    Index of the first row in `rows`
  • rowsAlways

    array of one of several shapes

    This page of rows
  • nextOffsetAlways

    number, may be null

    Pass as `offset` for the next page; null on the last
  • hunksAlways

    array of object

    Every hunk of the file with its line ranges, on every page
  • hunks[].​rowAlways

    number

    Index of the hunk's header row in this layout
  • hunks[].​oldStartAlways

    number

    First old-side line of the hunk
  • hunks[].​oldCountAlways

    number

    Old-side lines the hunk spans
  • hunks[].​newStartAlways

    number

    First new-side line of the hunk
  • hunks[].​newCountAlways

    number

    New-side lines the hunk spans
  • maxLineCharsAlways

    number

    Length of the longest line in the file, as sent
  • lastOldLineAlways

    number

    Last old-side line the diff shows (for the tail expander)
  • lastNewLineAlways

    number

    Last new-side line the diff shows
  • highlightedAlways

    boolean

    Rows carry `html`
  • patchBytesAlways

    number

    Size of the file's patch

Checked against the handlers: every route test validates their answers against this schema.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow git:PullRepository on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud git commits file-diff repoId sha --path example

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_git_commits_file-diff.