# lilgit

A read-only git HTTP(S) frontend for [Lilush](https://lilush.link):
`git clone`/`fetch` over smart-HTTP plus a browsing UI — repo index,
directory trees at any ref, markdown/djot rendered as HTML, raw file
serving. Everything is served straight from the git object database:
bare repositories work, no worktree or checkout is ever needed.

Pushes to served repositories appear immediately — the git core's
mtime caches invalidate themselves. `git push` over HTTP is refused;
push over ssh to the bare repo instead.

## URL scheme

| Path | Behavior |
|---|---|
| `/` | repo index |
| `/{repo}` | redirect to the default-branch tree |
| `/{repo}/tree/{ref}/{path}/` | directory listing, README rendered below |
| `/{repo}/blob/{ref}/{path}` | markdown/djot as HTML; source as text; images/binaries raw |
| `/{repo}/raw/{ref}/{path}` | raw bytes, extension-guessed MIME |

`{ref}` is a branch (slashes allowed), tag, full `refs/...` path,
`HEAD`, or a full 40-hex sha; sha-pinned URLs are served as immutable.
Clone URLs (`/{repo}` or `/{repo}.git`) coexist with browse URLs.

## Configuration

Read from `LILGIT_CONFIG_FILE` (default `/etc/lilgit/config.json`); a
missing file means pure defaults. CLI flags (`--ip`, `--port`, `--dir`,
`--title`) override everything.

```json
{
    "ip": "127.0.0.1",
    "port": 8091,
    "site_title": "my code",
    "repos_dir": "/srv/git",
    "repos": [
        {
            "name": "lilush",
            "path": "/srv/git/lilush.git",
            "description": "Linux Shell & Lua Framework",
            "default_branch": "master"
        }
    ],
    "ssl": { "default": { "cert": "...", "key": "..." } }
}
```

Repositories are discovered in `repos_dir` at startup (dirs with `HEAD`
or `.git/HEAD`); explicit `repos` entries win on name collision. The
`ssl` table enables built-in TLS (SNI-capable); omit it when running
behind a reverse proxy.

## Tests

Run from the pack root:

```
lilush tests/run.lua
LILGIT_E2E=1 lilush tests/run.lua
```

The e2e spec forks a real server and drives it with the git and curl
binaries.
