Skip to content

krishna4040/BYO-git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Modern VCS (mvcs)

A modern version control system built in Rust, inspired by Git and Jujutsu (jj).

Features

Core VCS Features

  • Repository Management: Initialize, clone, and manage repositories
  • Content-Addressable Storage: Efficient object storage with deduplication
  • Staging Area: Track changes and prepare commits
  • Commit System: Create and manage commits with metadata
  • Branch Management: Create, switch, and merge branches
  • Diff Engine: Compare files and generate patches
  • Three-Way Merging: Automatic conflict resolution with manual fallback
  • Remote Operations: Push, pull, and sync with remote repositories

Modern Features (inspired by jj)

  • Operation Log: Track all repository operations with undo capability
  • Change IDs: Immutable identifiers for changes
  • Working Copy as Commit: Treat working directory as a commit
  • Describe Command: Update commit messages after creation
  • New Command: Create new changes based on existing ones

Production-Ready Features

  • Comprehensive Error Handling: Detailed error messages and recovery
  • Cross-Platform Support: Works on Windows, macOS, and Linux
  • Efficient Storage: Compressed object storage
  • Conflict Resolution: Advanced merge conflict handling
  • Configuration Management: User and repository settings
  • CLI Interface: Full-featured command-line interface

Installation

cargo install --path .

Quick Start

Initialize a repository

mvcs init

Configure user (global)

mvcs config --global user.name "Your Name"
mvcs config --global user.email "[email protected]"

Add files and commit

mvcs add .
mvcs commit -m "Initial commit"

Create and switch branches

mvcs branch feature-branch
mvcs checkout feature-branch

View status and history

mvcs status
mvcs log
mvcs diff

Work with remotes

mvcs remote add origin https://example.com/repo.git
mvcs push origin main
mvcs pull origin main

Commands

Basic Commands

  • mvcs init [directory] - Initialize a new repository
  • mvcs clone <url> [directory] - Clone a repository
  • mvcs add <files> - Add files to staging area
  • mvcs commit -m "message" - Create a commit
  • mvcs status - Show working tree status
  • mvcs log - Show commit history
  • mvcs diff - Show changes

Branch Commands

  • mvcs branch - List branches
  • mvcs branch <name> - Create a branch
  • mvcs branch -d <name> - Delete a branch
  • mvcs checkout <branch> - Switch branches
  • mvcs checkout -b <name> - Create and switch to branch

Merge Commands

  • mvcs merge <branch> - Merge a branch
  • mvcs merge --no-ff <branch> - Force merge commit

Remote Commands

  • mvcs remote add <name> <url> - Add a remote
  • mvcs remote list - List remotes
  • mvcs push <remote> <branch> - Push to remote
  • mvcs pull <remote> <branch> - Pull from remote

Advanced Commands

  • mvcs show <object> - Show object details
  • mvcs reset [--hard|--soft] [commit] - Reset to commit
  • mvcs describe -m "message" [change] - Update commit message
  • mvcs new [base] - Create new change
  • mvcs oplog - Show operation log

Architecture

Object Storage

  • Blobs: File content
  • Trees: Directory structure
  • Commits: Snapshots with metadata
  • Compressed Storage: All objects are compressed with zlib

Index/Staging

  • Staging Area: Prepare commits incrementally
  • Conflict Resolution: Handle merge conflicts with stages
  • File Status Tracking: Track added, modified, deleted files

Repository Structure

.mvcs/
├── objects/          # Content-addressable object storage
├── refs/
│   ├── heads/        # Branch references
│   └── remotes/      # Remote branch references
├── index             # Staging area
├── HEAD              # Current branch/commit reference
├── config            # Repository configuration
└── oplog             # Operation log

Modern Features

Operation Log

Every operation is logged with:

  • Operation ID and timestamp
  • User information
  • Before/after commit hashes
  • Operation description

Change IDs

Each commit has:

  • Content hash (traditional)
  • Change ID (immutable, survives rebases)

Working Copy as Commit

  • Working directory is treated as a commit
  • Enables advanced workflows
  • Simplifies conflict resolution

Development

Building

cargo build --release

Testing

cargo test

Running

cargo run -- <command>

Comparison with Git

Feature Git mvcs
Object Storage
Branches
Merging ✓ (improved)
Remotes
Operation Log
Change IDs
Working Copy Commits
Conflict Resolution Basic Advanced

Comparison with Jujutsu

Feature jj mvcs
Change IDs
Operation Log
Working Copy Commits
Git Compatibility Partial
Conflict Resolution
Performance High High

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Roadmap

  • Git interoperability
  • Advanced merge algorithms
  • Distributed operation log
  • Web interface
  • IDE integrations
  • Performance optimizations
  • Advanced conflict resolution UI

About

build your own VCS in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages