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":"diff@example.com"}}}
{"diff_chunk":{"data":"ZGlmZiAtLWdpdCAuLi4=","eof":false}}
{"diff_chunk":{"data":"K25ldyBmaWxlIG1vZGUgMTAwNjQ0\n","eof":true}}

Request Body Fields

target_branch
string
required
Destination branch
commit_message
string
required
Commit message
author
string
required
Object with name and email
expected_head_sha
string
Guard ensuring the branch tip matches before applying the patch
base_branch
string
Seed when the target branch does not exist yet
committer
string
Object with name and email
ephemeral
string
Same semantics as commit-pack
ephemeral_base
string
Same 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

404 Not Found
string
Branch doesn’t exist
401 Unauthorized
string
Invalid JWT or missing git:write scope
400 Bad Request
string
Invalid request format or diff cannot be applied