repository

BVCS

A super suckless POSIX version control system

version 1.2.4 · MIT · 2026-11-23 · releases

103 lines · 4.6 KB · view it drawn · download this file

# BVCS

**BVCS** is a small, experimental version control tool written in POSIX shell (`/bin/sh`). It stores named snapshots of a working directory and lets you restore one of those snapshots using a simple command-line interface.

The program consists of a single shell script, with no third-party runtime dependencies. BVCS is a learning-oriented snapshot tool rather than a substitute for Git or another production version control system.

## Features

- Initialize a repository in the current directory.
- Save the current directory under a user-supplied commit ID.
- List saved commit IDs.
- Restore the working directory from a saved snapshot.
- Run with a POSIX-compatible shell and standard Unix utilities.

## Requirements

- A POSIX-compatible shell (`/bin/sh`)
- Standard utilities: `cp`, `rm`, `mkdir`, `ls`, `grep`, and `test`

The script is aimed at Unix-like systems. It does not require Git, Python, or a package manager.

## Installation

Extract the distribution archive and make the script executable:

```sh
tar -xzf bvcs-main.tar.gz
cd bvcs-main
chmod +x bvcs
```

You can invoke it from this directory with `./bvcs`, or install it somewhere on your `PATH`:

```sh
doas cp bvcs /usr/local/bin/bvcs
```

On systems without `doas`, use your normal administrative installation method. Alternatively, copy the script to a directory owned by your user that is already on `PATH`.

## Quick start

Run the following commands in a **disposable test directory** until you are familiar with the checkout behavior:

```sh
mkdir bvcs-demo
cd bvcs-demo
bvcs init
printf 'First version\n' > example.txt
bvcs commit first
printf 'Second version\n' > example.txt
bvcs commit second
bvcs log
bvcs checkout first
cat example.txt
```

If you haven't installed the command on `PATH`, use the full path to the `bvcs` script instead.

The final `cat` should print `First version` after the first snapshot is restored.

## Commands

| Command | Description |
| --- | --- |
| `bvcs init` | Create a `.bvcs` directory in the current directory, if it does not already exist. |
| `bvcs commit <id>` | Copy the current working directory into a snapshot named `<id>`. |
| `bvcs log` | List entries inside `.bvcs` (snapshot IDs). |
| `bvcs checkout <id>` | Delete non-`.bvcs` entries in the working directory and restore the specified snapshot. |
| `bvcs help` | Display the built-in help message. |

### Repository layout

After initializing and committing, a repository uses a layout similar to:

```text
project/
├── .bvcs/
│   └── first/
│       └── ... snapshot contents ...
└── example.txt
```

Snapshots are directories rather than diffs. Commit IDs are chosen manually; there is no automatic numbering, timestamping, branch management, or commit message metadata.

## Important limitations and safety warnings

**This version has known limitations. Use it only with files you have backed up elsewhere.**

- **Checkout destroys uncommitted work.** `bvcs checkout <id>` removes entries in the current working directory (other than `.bvcs`) before copying the chosen snapshot back. There is no confirmation prompt or safety check.
- **Commit snapshots include repository metadata.** The implementation recursively copies the entire current directory, including `.bvcs`, into each new snapshot. Repeated commits can cause substantial, rapidly increasing disk usage.
- **No protection against arbitrary commit IDs.** The script uses the supplied ID as part of a filesystem path and does not validate it. Use simple names consisting of letters, numbers, hyphens, and underscores; do not pass paths or `..`.
- **Whitespace and unusual filenames are not handled reliably.** Some filesystem paths are unquoted and filenames are iterated using shell word splitting. Work only in simple paths with simple filenames for testing.
- **The temporary location is fixed.** Commits use `$HOME/.bvcs_temp_dir` as a staging directory; an existing directory at that location may be removed.
- **No integrity or error-recovery guarantees.** The script does not consistently stop on failed copy/remove operations and does not support atomic commits, file-level tracking, merges, branches, remotes, or ignore rules.
- **`log` requires repository contents.** The command lists entries in `.bvcs` but does not provide a formatted history or verify that the current directory was initialized.

To make BVCS suitable for important projects, the snapshot process should exclude `.bvcs`, validate inputs, quote paths safely, isolate temporary data, and avoid destructive checkout without checks.

## License

Released under the **MIT License**. See [LICENSE](LICENSE) for the full text.

Copyright (c) 2023 KLD997.