Skip to content
GitmoapAPIBeta
Codediffs
GET/repositories/{repo_id}/merge-requests/{mr_id}/stack/diff

Cumulative diff of a merge request's downstack

get_stack_diff
  • diff:read
    A token needs the diff:read scope: View commit, merge-request, and branch-comparison diffsGranted by mcp_agent, mcp_agent_write, read_api, read_repository, write_api, write_repository.Every operation this scope unlocks
  • Metered egress · in band body

    x-gitmoap-egress: {"kind":"metered","arg":"in_band_body"}

  • Cacheable · derived SHA artifact

    x-gitmoap-cache: {"kind":"derived_sha_artifact"}

The net change of a stack from its base branch up to this merge request — what merging the stack up to here would apply — rather than this merge request's own layer. Lists the merge requests it rolls up, base first, and pages files like the other diffs.

Parameters

Path
  • repo_idRepositoryId (string · uuid)Repository ID
  • mr_idMergeRequestId (integer · int64)Anchor merge request ID (top of the rolled-up chain)
Query
  • pageintegeroptionalPage number (0-based). Default: 0
  • limitintegeroptionalFiles per page (1-100). Default: 20
  • include_patchbooleanoptionalInclude unified diff patch content. Default: false
  • collapsebooleanoptionalAuto-collapse generated/oversized file patches (fetch them via /diff-file). Default: true

Responses

200Cumulative downstack diffapplication/json
  • anchor_mr_idMergeRequestId (integer · int64)The merge request the diff is anchored on (top of the rolled-up chain).
  • base_branchBranchName (string)The stack base — the bottom-most target branch the diff is taken against.
  • diffDiffResponseThree-dot cumulative diff merge_base(base_branch, anchor_source) … anchor_source. diff.base_sha is that merge base, not the base tip.
    • The DiffResponse schema
    • base_shaCommitHash (string)
    • filesarray of DiffFile
      • The DiffFile schema
      • additionsinteger0–∞
      • collapsedbooleanThe patch was intentionally withheld (generated or oversized) to save bytes but is fetchable in full on demand via GET .../diff-file. Only ever set when patches were requested (include_patch=true).
      • deletionsinteger0–∞
      • generatedbooleanDetected generated/lock/minified file. Always computed from the path, independent of collapsed, so a client can badge or auto-fold it.
      • is_binaryboolean
      • patch_truncatedbooleanThe patch exceeds the hard per-file size cap and is omitted. Unlike collapsed, this file is not expandable in place — a client reads it piece-by-piece via GET .../file-lines instead.
      • pathstring
      • statusDiffFileStatusaddedmodifieddeletedrenamedcopied
      • collapse_reasonCollapseReasongeneratedlargeor nulloptionalWhy a file's patch body was withheld from a DiffFile (see collapsed). Distinct from patch_truncated, which marks a patch too large to ever send; a collapsed file's patch is fetchable on demand via GET .../diff-file.
      • old_pathstring or nulloptional
      • patchstring or nulloptional
    • has_morebooleanAnother page follows this one.
    • head_shaCommitHash (string)
    • pageinteger0–∞The page returned, from 0.
    • statsDiffStats
      • The DiffStats schema
      • additionsinteger0–∞Lines added across the whole change.
      • deletionsinteger0–∞Lines deleted across the whole change.
      • files_changedinteger0–∞Every file the change touches.
    • total_filesinteger0–∞How many files the pages can reach — every changed file, unless truncated.
    • truncatedbooleanThe change touches more files than any page can reach. stats still counts all of them.
  • member_mr_idsarray of MergeRequestId (integer · int64)The downstack merge requests rolled into this diff, base-first (the anchor is last).
  • repository_idRepositoryId (string · uuid)
200 exampleSynthesized example
{
"anchor_mr_id": 42,
"base_branch": "refactor/brand-inline",
"diff": {
"base_sha": "648349c87787748bb12ad198ac2c304be756bbc2",
"files": [
{
"additions": 37,
"collapsed": false,
"deletions": 63,
"generated": false,
"is_binary": false,
"patch_truncated": false,
"path": "path-e45b",
"status": "added"
},
{
"additions": 23,
"collapsed": false,
"deletions": 58,
"generated": false,
"is_binary": false,
"patch_truncated": false,
"path": "path-9a43",
"status": "added"
}
],
"has_more": false,
"head_sha": "21bca57d07e64618bb4748a2ff275bc036b087fc",
"page": 43,
"stats": {
"additions": 52,
"deletions": 86,
"files_changed": 84
},
"total_files": 4,
"truncated": false
},
"member_mr_ids": [
42,
42
],
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70"
}
400Bad request — a path parameter is not a well-formed value of its typeapplication/json
Error codes
  • BAD_REQUESTThe request is malformed: a parameter or a body field is not a well-formed value of its type
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
400 exampleSynthesized example
{
"error": {
"code": "code-df6d",
"message": "Label every synthesized example"
}
}
401Unauthenticated — no credential, or an invalid oneapplication/json
Error codes
  • UNAUTHORIZEDNo credential was sent, or the one sent is invalid, expired or revoked
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
401 exampleSynthesized example
{
"error": {
"code": "code-fc40",
"message": "Draw the region map from operation density"
}
}
403Forbidden — the caller's access level or token scope is insufficientapplication/json
Error codes
  • FORBIDDENYou are signed in but may not do this here; reason names the permission or the rule that refused it
  • INSUFFICIENT_SCOPEThe access token lacks the scope this operation needs; required_scope names it
  • PERMISSION_REQUIREDYou need a permission you do not hold here; the message names it
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
403 exampleSynthesized example
{
"error": {
"code": "code-0acc",
"message": "Pin a page's payload to the build that rendered it"
}
}
404Repository or merge request not foundapplication/json
Error codes
  • NOT_FOUNDThe resource does not exist — or exists and you cannot see it: a private resource you have no access to answers exactly as an absent one does
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
404 exampleSynthesized example
{
"error": {
"code": "code-cac0",
"message": "Label every synthesized example"
}
}

CLI

gitmoap diffs get-stack-diff

  • --repo-ididRepository ID (id or owner/repo path)
  • --mr-ididAnchor merge request ID (top of the rolled-up chain)
  • --collapseflagoptionalAuto-collapse generated/oversized file patches (fetch them via /diff-file). Default: true
  • --include-patchflagoptionalInclude unified diff patch content. Default: false
  • --limitnumberoptionalFiles per page (1-100). Default: 20
  • --pagenumberoptionalPage number (0-based). Default: 0

Used in these guides