Skip to main content
Create a commit by streaming a Git patch instead of individual file blobs.
POST /api/v1/repos/diff-commit
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/x-ndjson

Request Format

Like commit-pack, the payload is newline-delimited JSON. Send a metadata object first, followed by one or more diff_chunk entries.
{"metadata":{"target_branch":"main","expected_head_sha":"d34db33fd34db33fd34db33fd34db33f","commit_message":"Apply generated patch","author":{"name":"Diff Bot","email":"[email protected]"}}}
{"diff_chunk":{"data":"ZGlmZiAtLWdpdCAuLi4=","eof":false}}
{"diff_chunk":{"data":"K25ldyBmaWxlIG1vZGUgMTAwNjQ0\n","eof":true}}

Request Body Fields

ParameterTypeDescription
target_branchRequiredDestination branch
commit_messageRequiredCommit message
authorRequiredObject with name, email, and optional ISO 8601 timestamp
expected_head_shaOptionalGuard ensuring the branch tip matches before applying the patch
base_branchOptionalSeed when the target branch does not exist yet
committerOptionalObject with name, email, and optional ISO 8601 timestamp
ephemeralOptionalSame semantics as commit-pack
ephemeral_baseOptionalSame semantics as commit-pack

Diff Chunks

  • diff_chunk.data contains base64-encoded diff bytes; decoded payloads must be ≤ 4 MiB
  • Chunks are streamed sequentially; set "eof": true on the final chunk
  • The combined diff must be compatible with git apply --cached --binary (include file headers, mode lines, and hunk metadata)

JWT Requirements

  • The JWT must include the repository in the repo claim
  • Requires git:write scope

Response

The service returns the same schema as commit-pack responses.
{
  "commit": {
    "commit_sha": "8f12c3bd0f4ff7bfb7267e7a61b3c4a8712a10b2",
    "tree_sha": "b9532c5d5be50d88e2f45d7c229566b2f1f99731",
    "target_branch": "main",
    "pack_bytes": 5421
  },
  "result": {
    "branch": "main",
    "old_sha": "c4f0fdfc41adab56630b34f5f4fd4e84a2c5b4d2",
    "new_sha": "8f12c3bd0f4ff7bfb7267e7a61b3c4a8712a10b2",
    "success": true,
    "status": "ok",
    "message": ""
  }
}

Notes

  • result.success is false when the diff cannot be applied (for example, conflicts or empty diffs) and status reflects the mapped reason (conflict, precondition_failed, etc.)

Error Responses

StatusDescription
404 Not FoundBranch doesn’t exist
401 UnauthorizedInvalid JWT or missing git:write scope
400 Bad RequestInvalid request format or diff cannot be applied