Team Blaze Β· DSCPP-III-2026-T296 Β· CSE (AI&ML)
Department of Computer Science & Engineering β Graphic Era (Deemed to be University)
MiniGit is a lightweight, local, terminal-based version control system implemented in C++. Designed as an educational version control system, MiniGit demystifies core VCS conceptsβrepository initialization, staging areas, ignore rule management, and commit workflowsβwhile directly applying foundational computer science data structures such as Tries (Prefix Trees), an ordered set, a double-ended queue (undo/redo), and a doubly linked list (commit log).
MiniGit follows a modular 5-layer architecture:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. CLI Interface & Argument Parser β
β (Tokenizes input, validates flags: -r, -v, ., etc.) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2. Command Handler & Dispatcher (Abhinesh's Module) β
β (Maps commands -> operations; handles status codes) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3. Repository & Staging Manager β
β (.minigit/ structure, index persistence, undo/redo) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4. Ignore Engine (Trie Data Structure) β
β (Dual Prefix Trees: Path Trie & Reversed Ext Trie) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 5. Storage Layer (File I/O) β
β (.minigit/objects, .minigit/index, .minigit/HEAD) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
minigit init: Creates.minigit/(objects/,refs/heads/,HEAD=ref: refs/heads/main,index) and.minigitignore. Re-running it never overwrites existing data, and every failed write is reported.- Table-Driven Command Dispatcher: One table row per command holds its name, aliases, usage forms and handler.
minigit help,minigit help <command>,minigit <command> --helpand the usage printed on wrong arguments are all generated from it, so they cannot go out of date. - Typo Suggestions: An unknown command is matched to the closest real one by Levenshtein edit distance (
minigit comitβ The most similar command is commit). - Status & Error Mapper: Turns result structs (
InitResult,AddResult,IgnoreResult,CommitResult,LogResult) into messages and exit codes (0 = success, 1 = error). - Ignore CLI Interface: Validates
ignore,ignore -randignore -vinput; rejects empty patterns and anything outside the repository (.., absolute paths, drive letters). - First-Run Self-Installation: Copies the executable into the user's
PATHon first run, and refreshes that copy when a newer build is run.
-
Trie (Prefix Tree) Engine: Dual-Trie architecture for fast
$O(L)$ pattern matching without disk scans. -
Staging Area (
.minigit/index): Holds one normalized relative path per line with duplicate staging prevention. -
Add Operations: Supports single file tracking (
add <file>), batch repository staging (add .), and unstaging (remove <file|dir|.>).
minigit commit: Saves each staged file's content under.minigit/objects/<id>/snapshot/, writesmetadata(parent, timestamp, author, message, files) and movesHEAD. The commit id is a SHA-1 of that content.- Undo / Redo (
std::deque): Two deques of repository states. A new commit clears the redo deque; the undo deque is capped at 20 entries withpop_front(). Persisted in.minigit/history.
minigit log: Rebuilds the history fromHEADby following parent links into a doubly linked list, then walks it backward (newest first) or forward with--reverse.
Used for instant, deterministic pattern matching to block ignored files from staging:
-
Forward Path Trie: Stores exact file paths (
secret.txt) and directory rules (build/). Traverses path tokens in$O(L)$ time. -
Reversed Extension Trie: Stores wildcard extension patterns (e.g.
*.logis stored as reversed keygol.). When evaluating a filename, its reversed extension is queried in$O(E)$ time. -
Line Number Indexing: Every terminal Trie node stores the 1-based line number of the matching rule from
.minigitignore, allowing instant rule tracking during verification.
- Maintains staged file paths in
.minigit/index(one path per line). - Held in memory as
std::set(a red-black tree):$O(\log n)$ duplicate staging prevention and status checks, and entries stay sorted so the index file has a stable order.
-
std::dequegives$O(1)$ push_back/pop_backfor undo and redo, and$O(1)$ pop_frontto drop the oldest state once the 20-entry history limit is reached.
- Each
CommitNodelinks to the older and newer commit, sologandlog --reverseare both a single$O(n)$ walk from one end of the list.
| Command | Action / Dispatcher Function | Description |
|---|---|---|
minigit init |
initRepo() |
Initializes a local repository structure (.minigit/, HEAD, refs/heads/, index) |
minigit add <file|dir> |
addFile(path) |
Stages a file, or every non-ignored file in a directory |
minigit add . |
addAll() |
Recursively stages all unignored files in the repository |
minigit add -v <file> |
addVerify(path) |
Verifies if file is staged (prints '<file>' is staged via IS_STAGED) |
minigit remove <file|dir> |
removeFile(path) |
Unstages a file, or every staged file in a directory, without touching the working tree |
minigit remove . |
removeFile(".") |
Clears all staged files from the staging area |
minigit ignore |
IgnoreManager::lines() |
Lists the rules in .minigitignore with line numbers |
minigit ignore <pattern> |
ignoreAdd(pattern) |
Validates and appends <pattern> to .minigitignore and updates the Trie |
minigit ignore -r <pattern> |
ignoreRemove(pattern) |
Removes <pattern> from .minigitignore (or reports "not present") |
minigit ignore -v <path> |
ignoreVerify(path) |
Checks if <path> is ignored; returns exact rule and line number |
minigit commit "<message>" / commit -m "<message>" |
commitRepo(message) |
Records the staged files as a new commit and clears the index |
minigit commit undo / undo |
undoCommit() |
Moves HEAD back one commit and restores its staged files |
minigit commit redo / redo |
redoCommit() |
Re-applies the last undone commit |
minigit log [--reverse] |
showLog(reverse) |
Shows the commit history, newest first (oldest first with --reverse) |
minigit help [<command>] |
command table | Lists every command, or the usage of one (minigit <command> --help also works) |
minigit install |
CLI::install() |
Manually copies minigit into the user's PATH |
minigit uninstall |
CLI::uninstall() |
Removes minigit from user PATH |
- Compiler:
g++(GCC 6.3+ or modern Clang/MSVC, supports C++14/C++17) - Build Tool: GNU
makeormingw32-make
From the repository root:
# Compile standalone executable minigit
make allThe project includes automated test suites covering all modules:
# Run all unit tests
make testTest coverage includes:
test_trie: Forward/reversed Trie pattern matching, wildcard extensions, and node pruning.test_add: Staging, duplicate prevention, ignore enforcement, and persistence.test_init: Repository creation, metadata structure, and reinitialization handling.test_cli: Full CLI dispatching, argument validation, generated help, typo suggestions, and theIS_STAGEDprint case.test_commit: Commit ids and metadata, snapshots, undo/redo and the history limit, multi-line messages.test_commitlog: The doubly linked list on its own (insert, find, cursor movement).test_log:log/log --reverseover real commits, after undo, and through the CLI.
make cleanBy default, PowerShell and Unix terminals restrict running local executables without prefixing .\ or ./.
MiniGit includes built-in zero-config self-installation:
- The first time
.\minigitis run on a Windows 10/11 system, it automatically copies itself into%LOCALAPPDATA%\Microsoft\WindowsApps\minigit.exe. - Because this directory is already in the user's
PATHby default and requires no administrator privileges, you can immediately run:from any folder or terminal window on your machine.minigit init minigit add . minigit ignore -v secret.txt
MiniGit-CLI/
βββ .gitignore # Ignores build artifacts, temporary test files, and local repo state
βββ LICENSE # MIT License
βββ Makefile # Top-level build orchestration
βββ README.md # Project documentation
βββ Reports/ # Phase evaluation documentation
β βββ ppt.pdf # Phase-I presentation slides
β βββ report.pdf # Phase-I project proposal & architecture report
βββ module/ # Core source code & unit tests
βββ Makefile # Module compilation and test runners
βββ include/ # Header declarations
β βββ AddCommand.h # add / add . / add -v / remove interface
β βββ CLI.h # CLI parser, dispatcher, and status mapper
β βββ CommitCommand.h # commit / undo / redo interface
β βββ CommitHistory.h # Undo/redo deques (.minigit/history)
β βββ CommitLog.h # Doubly linked list over commits
β βββ CommitNode.h # One commit (list node)
β βββ IgnoreManager.h # .minigitignore parser & Trie bridge
β βββ InitCommand.h # initRepo interface
β βββ LogCommand.h # log / log --reverse interface
β βββ PathUtils.h # Path normalization & safety utilities
β βββ StagingArea.h # .minigit/index persistence manager
β βββ Trie.h # Pure Prefix Tree data structure
β βββ filesystem # Cross-compiler filesystem wrapper
β βββ ghc/ # Header-only standard filesystem implementation
βββ src/ # Implementation files
β βββ AddCommand.cpp
β βββ CLI.cpp # Command table, dispatcher and output
β βββ CommitCommand.cpp
β βββ CommitHistory.cpp
β βββ CommitLog.cpp
β βββ IgnoreManager.cpp
β βββ InitCommand.cpp
β βββ LogCommand.cpp
β βββ StagingArea.cpp
β βββ Trie.cpp
β βββ main.cpp # Production CLI entry point
β βββ main_demo.cpp # Standalone demo interface (add/ignore)
β βββ main_demo_log.cpp # Standalone demo interface (log)
βββ tests/ # Automated unit tests
βββ test_add.cpp
βββ test_cli.cpp
βββ test_commit.cpp
βββ test_commitlog.cpp
βββ test_init.cpp
βββ test_log.cpp
βββ test_trie.cpp
MiniGit is released under the MIT License.