examples
Three CLI scripts that use ply as the git client from a machine with Node and no git binary. Each is a thin wrapper over a first-class API; test/examples.test.js runs all three, as a user would, against git http-backend with the client's PATH holding only node.
npm install # once, in a clone: builds dist/, which the examples import as `ply` (no build, no examples)
export PLY_TOKEN=… # Basic auth (user PLY_USER, default x-access-token); or PLY_BEARER for Bearer
node examples/push-tree.mjs ./site https://host/repo.git --ref main --message "deploy"
node examples/checkout-tree.mjs https://host/repo.git ./out --ref main
node examples/push-repo.mjs ./repo https://host/repo.git main --tagsCredentials come from the environment only, never argv (argv shows up in ps and shell history). Author is GIT_AUTHOR_NAME / GIT_AUTHOR_EMAIL.
push-tree.mjs <dir> <remote> [--ref main] [--message …]—pushDir(ply/tree-node): the directory as one commit. Creates the ref with the zero old-oid, or updates it with its current head as the CAS. Prints the old → new commit, the objects sent and the pack bytes. The push is thin: whatever the previous commit already has is left out, so a repeat with one file changed sends that blob, the trees on its path and the commit; a repeat with nothing changed is anoopand sends nothing..gitis skipped;.gitignoreis not read (givepushDirafilterfor that).checkout-tree.mjs <remote> <dir> [--ref main]—checkoutDir(ply/checkout-node): a ref (defaultHEAD) into an absent or empty directory, laid out asgit clonelays it out (100755executable,120000a symlink, a submodule an empty directory), every blob hash-checked as it streams. Prints the commit and the files, bytes and symlinks written. Three requests whatever the file count: ls-refs, ablob:nonetree fetch, one fetch for the blobs.push-repo.mjs <repo-dir> <remote> [refspec …] [--all] [--tags] [--force] [--dry-run] [--thin]—pushRepo(ply/repo-node):git pushof a local repository, history included, with ply reading.gititself. Refspecs are git's (main,src:dst,+src:dst,:dst); none pushes the current branch. Prints each ref's old → new (orEverything up-to-date, with nothing sent) and the objects, deltas and pack bytes. A non-fast-forward is refused before anything is sent (not_fast_forward) unless forced.
Measured by test/examples.test.js (9 files, 6 trees, two symlinks, an exec bit): create sends 16 objects / 4683 pack bytes; a one-file change four directories deep sends 6 objects (1 blob, 4 trees, the commit) / 488 bytes; an unchanged tree is a noop. The checkout is byte-identical to the source with modes, and so is git clone of the remote.