X Tutup
Skip to content

Add mempack ODB backend, Index.create, and Odb.addMempackBackend#2040

Open
jkoppel wants to merge 3 commits intonodegit:masterfrom
up-to-speed:mempack-backend
Open

Add mempack ODB backend, Index.create, and Odb.addMempackBackend#2040
jkoppel wants to merge 3 commits intonodegit:masterfrom
up-to-speed:mempack-backend

Conversation

@jkoppel
Copy link

@jkoppel jkoppel commented Mar 10, 2026

Exposes libgit2's mempack API so you can compute tree hashes in-memory without touching .git/objects/.

Partially addresses #1296 (adds the built-in mempack backend, but not arbitrary custom backends).

What's new

  • Mempack.create() — wraps git_mempack_new
  • Odb.prototype.addMempackBackend(backend, priority) — wraps git_odb_add_backend
  • Index.create() — wraps git_index_new (free-standing in-memory index)
  • Mempack.prototype.reset() — wraps git_mempack_reset

Usage

const repo = await NodeGit.Repository.open("/path/to/repo");
const odb = await repo.odb();

const mempack = await NodeGit.Mempack.create();
await odb.addMempackBackend(mempack, 999);

const index = await NodeGit.Index.create();
// ... add entries, then:
const treeOid = await index.writeTreeTo(repo); // writes to RAM, not disk

await mempack.reset();

Implementation notes

git_index_new was already known to the generator but ignored — just had to un-ignore it. The mempack/odb_backend stuff needed manual C++ bindings since git_odb_backend* isn't a type the generator handles. Added via cFile entries in libgit2-supplement.json, same pattern as the existing manual bindings for clone, revwalk, etc.

The vendored libgit2 already compiles odb_mempack.c so no build changes were needed beyond what the generator produces.

jkoppel and others added 3 commits March 10, 2026 20:30
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

X Tutup