API Reference
Compare
Compare two refs — merge base, ahead/behind counts, file diffs, and mergeability.
Compare Refs
GET /v1/repos/:slug/compare?base=main&head=feature-x
GET /v1/repos/:namespace/:slug/compare?base=main&head=feature-xReturns a full comparison between two refs: the merge base, how many commits each side is ahead/behind, file-level diffs with stats, and whether the head can be cleanly merged into the base.
base— Required. Branch name, tag, or commit SHAhead— Required. Branch name, tag, or commit SHA
Response 200:
{
"base": "7f3b...",
"head": "a1c2...",
"merge_base": "d4e5...",
"ahead_by": 3,
"behind_by": 1,
"commits": [
{
"sha": "b2c3...",
"message": "feat: add login page",
"author": "Agent",
"email": "agent@example.com",
"date": "2025-06-15T12:00:00.000Z"
}
],
"files": [
{
"path": "src/auth.ts",
"status": "modified",
"old_sha": "f6a7...",
"new_sha": "e8b9..."
},
{
"path": "src/login.ts",
"status": "added",
"old_sha": null,
"new_sha": "c3d4..."
}
],
"total_files_changed": 2,
"total_additions": 45,
"total_deletions": 3,
"mergeable": true,
"conflicts": []
}Fields
merge_base— The common ancestor commit ofbaseandheadahead_by— Number of commits inheadthat are not inbase(since merge base)behind_by— Number of commits inbasethat are not inhead(since merge base)commits— The ahead commits, oldest firstfiles— File-level diffs betweenmerge_baseandheadmergeable— Whetherheadcan be merged intobasewithout conflicts.nullif too many commits to check (> 50)conflicts— List of conflicting file paths (empty if mergeable)
File Statuses
| Status | Meaning |
|---|---|
added | New file in head |
modified | Changed between merge base and head |
removed | Deleted in head |
When Identical
If base and head resolve to the same SHA, the response returns zeros for all counts and an empty file list.
Error Cases
Returns 422 if no common ancestor exists between the two refs.