[**@fungi.computer/agar**](README.md) --- [@fungi.computer/agar](modules.md) / git-commit # git-commit ## Type Aliases ### GitCommitStore ```ts type GitCommitStore = Pick; ``` The binding operations these writes use. --- ### GitFileChange ```ts type GitFileChange = Readonly<{ path: string; content: Uint8Array | null; mode?: "100644" | "100755"; }>; ``` One file to write (`content`) or delete (`content: null`), repository-relative. --- ### GitIdentity ```ts type GitIdentity = Readonly<{ name: string; email: string; }>; ``` Name and email recorded as a commit's author and committer. --- ### CommitFilesRequest ```ts type CommitFilesRequest = Readonly<{ repository: string; branch: string; expectedHead: string | null; startFrom?: string; changes: readonly GitFileChange[]; message: string; author: GitIdentity; }>; ``` A commit of file changes to one branch. --- ### GitWriteOutcome ```ts type GitWriteOutcome = | Readonly<{ kind: "committed"; commit: string; }> | Readonly<{ kind: "unchanged"; commit: string; }> | Readonly<{ kind: "updated"; }> | Readonly<{ kind: "stale"; head: string | null; }>; ``` What a compare-and-swap write did. --- ### MergeBranchRequest ```ts type MergeBranchRequest = Readonly<{ target: string; source: string; branch: string; sourceBranch: string; expectedSource: string; expectedTarget?: string; behind?: number; message: string; author: GitIdentity; }>; ``` Merge a branch of `source` (such as a fork) into a branch of `target`. --- ### GitMergeOutcome ```ts type GitMergeOutcome = | Readonly<{ kind: "merged"; before: string; after: string; }> | Readonly<{ kind: "up-to-date"; head: string; }> | Readonly<{ kind: "conflict"; head: string; paths: readonly string[]; }> | Readonly<{ kind: "stale"; head: string | null; }> | Readonly<{ kind: "source-moved"; head: string; }>; ``` What a merge did. Merges always write a merge commit when there is new work. --- ### MoveRefRequest ```ts type MoveRefRequest = Readonly<{ repository: string; ref: string; expected: string | null; commit: string; source: string; }>; ``` Point a ref at a commit that is the head of `source`. --- ### MoveRefsRequest ```ts type MoveRefsRequest = Readonly<{ repository: string; source: string; commit: string; updates: readonly Readonly<{ ref: string; expected: string | null; }>[]; }>; ``` Ordered ref moves to one fetched source commit; each move has its own CAS guard. --- ### GitRefMovesOutcome ```ts type GitRefMovesOutcome = | Readonly<{ kind: "updated"; }> | Readonly<{ kind: "stale"; ref: string; head: string | null; }>; ``` Earlier moves remain accepted if a later ref is stale; this is not an atomic push. ## Functions ### commitFiles() ```ts function commitFiles(store, request, beforeWrite?): Promise; ``` Commit files using independently resumable, CAS-guarded Git steps. #### Parameters | Parameter | Type | | -------------- | ------------------------------------------- | | `store` | [`GitCommitStore`](#gitcommitstore) | | `request` | [`CommitFilesRequest`](#commitfilesrequest) | | `beforeWrite?` | () => `Promise`\<`void`\> | #### Returns `Promise`\<[`GitWriteOutcome`](#gitwriteoutcome)\> --- ### moveRef() ```ts function moveRef(store, request): Promise; ``` Point a ref at the head commit of `source`, compare-and-swap on the ref. #### Parameters | Parameter | Type | | --------- | ----------------------------------- | | `store` | [`GitCommitStore`](#gitcommitstore) | | `request` | [`MoveRefRequest`](#moverefrequest) | #### Returns `Promise`\<[`GitWriteOutcome`](#gitwriteoutcome)\> --- ### moveRefs() ```ts function moveRefs(store, request): Promise; ``` Fetch a source once, then move refs in order with separate guarded pushes. #### Parameters | Parameter | Type | | --------- | ------------------------------------- | | `store` | [`GitCommitStore`](#gitcommitstore) | | `request` | [`MoveRefsRequest`](#moverefsrequest) | #### Returns `Promise`\<[`GitRefMovesOutcome`](#gitrefmovesoutcome)\> --- ### mergeBranch() ```ts function mergeBranch(store, request): Promise; ``` Merge branches through the same one-exchange step engine as background owners. #### Parameters | Parameter | Type | | --------- | ------------------------------------------- | | `store` | [`GitCommitStore`](#gitcommitstore) | | `request` | [`MergeBranchRequest`](#mergebranchrequest) | #### Returns `Promise`\<[`GitMergeOutcome`](#gitmergeoutcome)\>