Liking cljdoc? Tell your friends :D

us.whitford.fulcro.rad.database-adapters.git.jgit

JGit in-process implementations of git read and write operations.

Repository objects are thread-safe and cached in a pool (one per directory). All read operations use Git/wrap (non-owning) for command construction. Write operations acquire a per-directory ReentrantLock before touching the index or committing — shell-outs serialized naturally, JGit in-process writes from concurrent futures need explicit coordination. The pool is closed at shutdown via close-all!.

Read operations provided:

  • log — git log with path filter + max-count
  • grep — git grep -i -n (TreeWalk over HEAD tree)
  • branch-list — git branch --list
  • resolve-head — git rev-parse HEAD (short + full)
  • is-bare? — git rev-parse --is-bare-repository
  • list-worktrees — git worktree list --porcelain (filesystem read)

Write operations provided:

  • commit-files! — stage + commit one or more files (add or delete)
  • commit! — stage + commit a single file (convenience wrapper)
JGit in-process implementations of git read and write operations.

Repository objects are thread-safe and cached in a pool (one per directory).
All read operations use Git/wrap (non-owning) for command construction.
Write operations acquire a per-directory ReentrantLock before touching the
index or committing — shell-outs serialized naturally, JGit in-process writes
from concurrent futures need explicit coordination.
The pool is closed at shutdown via `close-all!`.

Read operations provided:
- `log`            — git log with path filter + max-count
- `grep`           — git grep -i -n (TreeWalk over HEAD tree)
- `branch-list`    — git branch --list
- `resolve-head`   — git rev-parse HEAD (short + full)
- `is-bare?`       — git rev-parse --is-bare-repository
- `list-worktrees` — git worktree list --porcelain (filesystem read)

Write operations provided:
- `commit-files!`  — stage + commit one or more files (add or delete)
- `commit!`        — stage + commit a single file (convenience wrapper)
raw docstring

branch-listclj

(branch-list repo)

JGit equivalent of: git branch --list --format=%(refname:short)

Returns a set of branch name strings (without refs/heads/ prefix).

Arguments:

  • repo: JGit Repository object
JGit equivalent of: git branch --list --format=%(refname:short)

Returns a set of branch name strings (without refs/heads/ prefix).

Arguments:
- repo: JGit Repository object
sourceraw docstring

close-all!clj

(close-all!)

Close all cached Repository objects. Call at shutdown.

Close all cached Repository objects. Call at shutdown.
sourceraw docstring

commit!clj

(commit! repo dir file-path message)

JGit convenience wrapper for committing a single file. Equivalent of git add rel-path && git commit --only rel-path -m message.

Arguments:

  • repo: JGit Repository object
  • dir: directory containing the repo (used as lock key)
  • file-path: absolute path to the file to commit
  • message: commit message

Returns {:success bool :commit string-or-nil} or nil on failure.

JGit convenience wrapper for committing a single file.
Equivalent of `git add rel-path && git commit --only rel-path -m message`.

Arguments:
- repo: JGit Repository object
- dir: directory containing the repo (used as lock key)
- file-path: absolute path to the file to commit
- message: commit message

Returns {:success bool :commit string-or-nil} or nil on failure.
sourceraw docstring

commit-files!clj

(commit-files! repo dir file-specs message)

JGit equivalent of staging multiple files and committing them together. Each file-spec is {:path string (absolute), :action :add|:delete}. Files marked :delete must already be removed from disk before calling this.

Uses setOnly(path) on CommitCommand for each path — equivalent of git commit --only path1 path2 ... which is what the CLI implementation uses.

Write-serialized per directory via ReentrantLock — safe to call from futures.

Arguments:

  • repo: JGit Repository object
  • dir: directory string (used as lock key — should be worktree or repo dir)
  • file-specs: seq of {:path string :action :add|:delete}
  • message: commit message

Returns {:success bool :commit string-or-nil} where :commit is the new HEAD SHA (abbreviated) or nil if nothing was staged (no changes).

JGit equivalent of staging multiple files and committing them together.
Each file-spec is {:path string (absolute), :action :add|:delete}.
Files marked :delete must already be removed from disk before calling this.

Uses setOnly(path) on CommitCommand for each path — equivalent of
`git commit --only path1 path2 ...` which is what the CLI implementation uses.

Write-serialized per directory via ReentrantLock — safe to call from futures.

Arguments:
- repo: JGit Repository object
- dir: directory string (used as lock key — should be worktree or repo dir)
- file-specs: seq of {:path string :action :add|:delete}
- message: commit message

Returns {:success bool :commit string-or-nil} where :commit is the new HEAD SHA
(abbreviated) or nil if nothing was staged (no changes).
sourceraw docstring

delete-branch!clj

(delete-branch! repo branch)

Delete a branch ref from the repository. Equivalent of: git branch -D <branch> Does NOT check if the branch has an active worktree — caller's responsibility.

Arguments:

  • repo: JGit Repository
  • branch: branch name string (without refs/heads/ prefix)

Returns {:success bool} or nil on failure.

Delete a branch ref from the repository.
Equivalent of: git branch -D <branch>
Does NOT check if the branch has an active worktree — caller's responsibility.

Arguments:
- repo:   JGit Repository
- branch: branch name string (without refs/heads/ prefix)

Returns {:success bool} or nil on failure.
sourceraw docstring

delete-embed-refclj

(delete-embed-ref repo)

Delete refs/embed/v1/index. Returns true if deleted, false if it didn't exist.

Delete refs/embed/v1/index.
Returns true if deleted, false if it didn't exist.
sourceraw docstring

evict-repo!clj

(evict-repo! dir)

Remove and close a specific Repository from the pool. Useful when a repo directory is deleted (e.g. test cleanup).

Remove and close a specific Repository from the pool.
Useful when a repo directory is deleted (e.g. test cleanup).
sourceraw docstring

evict-write-lock!clj

(evict-write-lock! dir)

Remove the write lock for a directory. Called when a worktree is deleted so we don't accumulate stale locks.

Remove the write lock for a directory. Called when a worktree is deleted
so we don't accumulate stale locks.
sourceraw docstring

fork-worktree!clj

(fork-worktree! repo worktree-path branch start-point)

Add a worktree at worktree-path branching from start-point. Equivalent of: git worktree add <path> -b <branch> <start-point>

Arguments:

  • repo: JGit Repository (must be bare)
  • worktree-path: File — absolute path for the new worktree directory
  • branch: new branch name string
  • start-point: commit SHA, branch name, or any rev-parseable string

Returns {:success bool :path string :branch string} or nil on failure.

Add a worktree at worktree-path branching from start-point.
Equivalent of: git worktree add <path> -b <branch> <start-point>

Arguments:
- repo:          JGit Repository (must be bare)
- worktree-path: File — absolute path for the new worktree directory
- branch:        new branch name string
- start-point:   commit SHA, branch name, or any rev-parseable string

Returns {:success bool :path string :branch string} or nil on failure.
sourceraw docstring

gc!clj

(gc! repo & [{:keys [aggressive?]}])

Run git garbage collection on a repository. Equivalent of: git gc [--aggressive]

Arguments:

  • repo: JGit Repository
  • aggressive?: boolean — pass --aggressive flag

Returns {:success bool} or nil on failure.

Run git garbage collection on a repository.
Equivalent of: git gc [--aggressive]

Arguments:
- repo:        JGit Repository
- aggressive?: boolean — pass --aggressive flag

Returns {:success bool} or nil on failure.
sourceraw docstring

get-repoclj

(get-repo dir)

Get or open a cached Repository for the given directory. Returns the Repository or nil on error.

Get or open a cached Repository for the given directory.
Returns the Repository or nil on error.
sourceraw docstring

grepclj

(grep repo query & [{:keys [entity-dir]}])

JGit equivalent of: git grep -i -n query [-- entity-dir/]

Searches HEAD tree for case-insensitive matches. Returns vector of {:path string, :line string, :match string} where :line is the line number and :match is the matching line content.

Arguments:

  • repo: JGit Repository object
  • query: search string (quoted for regex safety)
  • opts: {:entity-dir string} — restrict search to directory prefix
JGit equivalent of: git grep -i -n query [-- entity-dir/]

Searches HEAD tree for case-insensitive matches. Returns vector of
{:path string, :line string, :match string} where :line is the line number
and :match is the matching line content.

Arguments:
- repo: JGit Repository object
- query: search string (quoted for regex safety)
- opts: {:entity-dir string} — restrict search to directory prefix
sourceraw docstring

init-bare!clj

(init-bare! dir)

Initialize a bare git repository at dir with an initial empty commit on main. Equivalent of: git init --bare --initial-branch=main <dir> (plus creating an empty commit so worktrees can branch from HEAD)

JGit bare repos can commit via an ObjectInserter — no temp worktree needed.

Arguments:

  • dir: File or path string for the new bare repository

Returns the canonical path string, or nil on failure.

Initialize a bare git repository at dir with an initial empty commit on main.
Equivalent of:
  git init --bare --initial-branch=main <dir>
  (plus creating an empty commit so worktrees can branch from HEAD)

JGit bare repos can commit via an ObjectInserter — no temp worktree needed.

Arguments:
- dir: File or path string for the new bare repository

Returns the canonical path string, or nil on failure.
sourceraw docstring

is-bare?clj

(is-bare? repo)

Returns true if the repository is bare.

Returns true if the repository is bare.
sourceraw docstring

list-worktreesclj

(list-worktrees repo)

Read worktree metadata from the filesystem. JGit 7.x has no WorktreeListCommand so we read the commondir/worktrees/ directory structure directly.

Returns vector of {:path string, :head string, :branch string, :bare bool}.

Read worktree metadata from the filesystem. JGit 7.x has no WorktreeListCommand
so we read the commondir/worktrees/ directory structure directly.

Returns vector of {:path string, :head string, :branch string, :bare bool}.
sourceraw docstring

logclj

(log repo {:keys [max-count path] :or {max-count 20}})

JGit equivalent of: git log --max-count=N --format=%H|%aI|%s -- rel-path

Arguments:

  • repo: JGit Repository object
  • opts: {:max-count int, :path string (repo-relative)}

Returns vector of {:hash string, :time string, :message string}.

JGit equivalent of: git log --max-count=N --format=%H|%aI|%s -- rel-path

Arguments:
- repo: JGit Repository object
- opts: {:max-count int, :path string (repo-relative)}

Returns vector of {:hash string, :time string, :message string}.
sourceraw docstring

prune-worktrees!clj

(prune-worktrees! repo)

Remove stale worktree metadata from commondir/worktrees/. Stale = gitdir pointer file references a path that no longer exists. Equivalent of: git worktree prune

Arguments:

  • repo: JGit Repository

Returns {:success bool :pruned int} — number of stale entries removed.

Remove stale worktree metadata from commondir/worktrees/.
Stale = gitdir pointer file references a path that no longer exists.
Equivalent of: git worktree prune

Arguments:
- repo: JGit Repository

Returns {:success bool :pruned int} — number of stale entries removed.
sourceraw docstring

read-blobclj

(read-blob repo sha)

Read a blob by its SHA hex string. Returns byte-array or nil if not found.

Read a blob by its SHA hex string. Returns byte-array or nil if not found.
sourceraw docstring

read-embed-refclj

(read-embed-ref repo)

Read the embedding index blob from refs/embed/v1/index. Returns byte-array or nil if the ref doesn't exist.

Read the embedding index blob from refs/embed/v1/index.
Returns byte-array or nil if the ref doesn't exist.
sourceraw docstring

resolve-headclj

(resolve-head repo)

Resolve HEAD to short and full SHA strings. Returns {:head-short string, :head-full string} or nil if no HEAD.

Resolve HEAD to short and full SHA strings.
Returns {:head-short string, :head-full string} or nil if no HEAD.
sourceraw docstring

walk-treeclj

(walk-tree repo)

Walk the HEAD tree and return all blob entries as [{:path :blob-sha}]. Returns empty vector if HEAD doesn't exist.

Walk the HEAD tree and return all blob entries as [{:path :blob-sha}].
Returns empty vector if HEAD doesn't exist.
sourceraw docstring

worktree-add!clj

(worktree-add! repo worktree-path branch)

Add a new worktree at worktree-path on a new branch. Equivalent of: git worktree add <path> -b <branch>

Uses JGit plumbing: branch ref creation + worktree metadata files + DirCacheCheckout to populate the working tree.

Arguments:

  • repo: JGit Repository (must be bare)
  • worktree-path: File — absolute path for the new worktree directory
  • branch: branch name string

Returns {:success bool :path string :branch string} or nil on failure.

Add a new worktree at worktree-path on a new branch.
Equivalent of: git worktree add <path> -b <branch>

Uses JGit plumbing: branch ref creation + worktree metadata files +
DirCacheCheckout to populate the working tree.

Arguments:
- repo:          JGit Repository (must be bare)
- worktree-path: File — absolute path for the new worktree directory
- branch:        branch name string

Returns {:success bool :path string :branch string} or nil on failure.
sourceraw docstring

worktree-remove!clj

(worktree-remove! repo worktree-path)

Remove a worktree directory and its metadata in commondir/worktrees/<name>/. Keeps the branch ref (historical access via git log). Equivalent of: git worktree remove --force <path>

Arguments:

  • repo: JGit Repository (the bare repo)
  • worktree-path: File — path of the worktree to remove

Returns {:success bool}.

Remove a worktree directory and its metadata in commondir/worktrees/<name>/.
Keeps the branch ref (historical access via git log).
Equivalent of: git worktree remove --force <path>

Arguments:
- repo:          JGit Repository (the bare repo)
- worktree-path: File — path of the worktree to remove

Returns {:success bool}.
sourceraw docstring

write-embed-refclj

(write-embed-ref repo data)

Write bytes as a blob and force-update refs/embed/v1/index. Returns true on success.

Write bytes as a blob and force-update refs/embed/v1/index.
Returns true on success.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close