Skip to content

About

Local version control system written in Go

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

89 Commits

Folders and files

Repository files navigation

SuperSourceControl

A local version control system written in Go. I built this as a way to introduce myself to Golang. (v2.1)

Installation

git clone https://github.com/mehtaarn000/SuperSourceControl
cd SuperSourceControl
go build ssc.go

Then, move the ssc executable file (generated by the Go compiler) to somewhere in your $PATH.

Quickstart

To start a project:

mkdir testdir
cd testdir
ssc init

Configure your identity once (also works before ssc init):

ssc config -c authorName "Your Name"
ssc config -c authorEmail "you@example.com"

Then, create a file and commit:

touch "hello world" > helloworld.txt
ssc commit -m "Initial commit"

Log all commits:

ssc log -m

Usage

Simpily run ssc --help to see usage.

Update version

On Unix-like systems, two dependencies are required. jq and curl. You can use your operating systems package manager to install these. When you are ready to update, run either of the following commands:

ssc update

or if you are using an older version of SuperSourceControl:

curl https://raw.githubusercontent.com/mehtaarn000/SuperSourceControl/master/update.sh | sh

Initialization and branches

ssc init creates the default branch from your settings, creating the settings file automatically on first use. Use ssc init -b main to choose a branch for a new repository. Running init in an existing repository fails without changing its history.

After making at least one commit, use:

ssc branch -n feature       # Create a branch with the current branch's history
ssc branch -s feature      # Switch to its latest committed snapshot
ssc branch -ns experiment  # Create and switch in one command
ssc branch -s main
ssc branch -d experiment   # Confirm deletion, or append --force

New branches inherit the complete current history, including the latest commit. Branch names may use namespaces such as feature/login, but a branch cannot also serve as a namespace for another branch. Existing branches cannot be recreated, and the active branch cannot be deleted.

Switching between different commit tips replaces working files with the target snapshot, including deleting files absent from it. Commit changes you want to keep before switching. Switching to the current branch or another branch at the same tip leaves working files alone. Missing or unreadable snapshot objects are checked before restoring files; an operating-system write failure during restoration can still leave a partially restored working directory.

Development checks

Run go test ./... for initialization and branch regression tests, and go build -o ssc . to build the CLI. Branch-name validation uses the Go standard library and does not require PCRE.

Commit authors and ancestry

New commits store the configured author name and email, timestamp, tree hash, branch name, and parent commit hash. The first commit has no parents; later commits point to the active branch's latest commit. Branches share their common ancestor and develop separate parent chains. All four commit-message modes (-m, -p, -f, and -e) use the same identity and parent handling.

ssc log -m displays the author alongside each commit's date and subject. ssc cat-file -c <hash> displays the full commit, including its parent header. Author information is self-declared metadata, not authentication or a signature. Changing your configuration affects future commits only.

The format supports multiple parent headers for a future merge implementation; ordinary commits currently write at most one. The Go API core.IsAncestor(ancestor, descendant) traverses stored parent links, independent of branch logs. It returns an error for missing/corrupt objects and core.ErrLegacyHistory when older objects prevent a definitive negative answer. Clone, push, and fast-forward pull are available through the shared server; merging is not implemented yet.

Existing objects are never rewritten. Legacy commits remain readable and appear in branch history with an unknown author. New commits can reference a legacy tip, but older ancestry cannot be inferred from those objects. Branch logs remain history indexes to retain access to legacy entries.

Version 2 commits use format 2, author-name, author-email, and zero or more parent headers before the blank line separating the message. Their object ID is the RIPEMD-160 hash of commit <decimal byte length>\0<body>; all metadata is included, and the commit reader verifies the ID. Tree/blob formats are unchanged. Older SSC binaries do not understand the new metadata; upgrade before writing commits with this version.

Commit writers use .ssc/commit.lock and publish completed compressed objects before replacing the branch history index. If a process is killed, remove a stale lock only after verifying no commit is running. This operation lock also covers push, pull, remote configuration, branch, and revert commands; commit holds it throughout snapshot creation. An interrupted write may leave an unreferenced object or temporary file.

For isolated settings, set SSC_CONFIG_FILE to a configuration-file path; otherwise SSC uses ~/.sscconfig.json. Existing configurations need only the two new author settings, and other preferences are preserved.

Shared repository server

SSC includes a Go HTTP server for shared object storage and branch tips, with hashed bearer-token authentication, repository-specific read/write permissions, and conditional branch updates that reject stale or divergent writes.

go build -o ssc .
./ssc serve --generate-token
./ssc serve --config server.json --data /path/to/ssc-server-data

See server setup and API documentation for the required configuration, TLS setup, protocol, and limits. The server requires Go 1.20 or newer. Client-side clone, push, and fast-forward pull are available. See the client guide for setup, authentication, and conflict behavior.

Clone, push, and pull

export SSC_TOKEN='your-access-token'
ssc clone https://ssc.example.com:8443/v1/repos/demo project
cd project
ssc config -c authorName "Your Name"
ssc config -c authorEmail "you@example.com"
# Edit files, then:
ssc commit -m "Implement a feature"
ssc push
# Get new commits from teammates:
ssc pull

The server repository must already exist. To connect an existing local SSC repository, run ssc remote <repository-url>. Push sends only missing objects; pull rejects uncommitted changes and divergent history. Read the client guide for checkout recovery and current limits.

About

Local version control system written in Go

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages