Files
git-cli/README.md
T
2026-08-09 14:42:54 +02:00

2.5 KiB

git

A small command-line-like Git module for Racket, implemented directly on top of the libgit2 package.

(require git)

(git 'status)
(git 'add "main.rkt" "info.rkt")
(git 'commit "Implement raco support")
(git 'tag "v0.2")
(git 'checkout "main")

;; Display-oriented variant:
(dgit 'status)

git is an ordinary procedure; command names are symbols. dgit performs the same operation, displays a compact human-readable result, and returns that result.

The same operations are available as normal procedures such as git-status, git-add, git-commit, git-tag, and git-checkout.

HTTPS credentials

Version 0.2 adds persistent HTTPS credentials. They are stored in the racket-git.ini file in Racket's preferences directory. Tokens are encrypted with AES-GCM using a key derived from the store password with PBKDF2-HMAC-SHA256.

Create the credential store once:

(git 'credentials 'init "store password")

Store a token for a Git host:

(git 'credentials 'set
     "https://git.dijkewijk.nl"
     "hans"
     token)

The host is used as the credential key, so the same entry is used for all HTTPS repositories on that host.

The store is unlocked for one day by default:

(git 'credentials 'unlock "store password")

or for an explicit number of seconds:

(git 'credentials 'unlock "store password" (* 8 60 60))

The temporary unlock state is stored in racket-git-unlock.ini in Racket's preferences directory, so it survives restarting DrRacket and starting a new Racket process. Both files are opened through simple-ini with #:private? #t; on Unix this restricts them to mode 0600 before sensitive contents are written. The cached derived key grants access to the credentials until its expiry, so racket-git-unlock.ini must be treated as sensitive during that period.

Lock immediately with:

(git 'credentials 'lock)

After credentials have been stored and the store is unlocked, normal remote operations use them automatically:

(git 'fetch)
(git 'pull)
(git 'push)

Supported Git operations

Version 0.2 supports repository discovery, init, clone, status, add, config, commit, branch, checkout, lightweight tags, log, remotes, fetch, fast-forward-only pull, push, tag push, and HTTPS username/token credentials.

SSH credentials, merge/rebase pull, annotated tags, and submodules are not yet part of this module.

Install from the package directory with:

raco pkg install .