Lit
is a simple version control system simulation built using C. It provides basic functionality like initializing a repository, adding files, committing changes, pushing to a remote repository, and viewing commit history. This project is compatible with both Windows and Linux environments.
- Key Features
- Project Structure
- Pre Requisites
- Setting Up the Project
- Usage
- Libraries Used
- Batch file Overview
- Makefile Overview
- Demo
- Future Scope
- Repository Initialization: Creates a new
.lit
directory within the local repository to store version control data. - File Addition: Stages files by adding them to the
.lit
directory inside the repository. - Commit System: Commits staged files with a unique hash and a user-provided commit message.
- Push Functionality: Pushes committed changes from the local repository to a simulated remote repository.
- Cross-Platform: Compatible with both Windows and Linux environments.
- Test Mode: Includes an automated test suite to ensure functionality.
Lit-Version-Control-Simulation/
├── bin/ # Binary files (executables) (created on build)
├── obj/ # Object files generated from source code (created on build)
├── src/ # Source code for the project
│ ├── lit.c # Core functionality (init, add, commit, push, history)
│ ├── file_handeling.c # File handling functions (create, copy, check existence)
│ ├── commit.c # Commit management (hashing, saving commits)
│ ├── main.c # Entry point of the program
│ ├── lit.h # Header for lit functions
│ ├── file_handeling.h # Header for file handling functions
│ ├── commit.h # Header for commit functions
├── test/ # Test file
│ ├── test_lit.c # Test suite for Lit system and different functions
├── build.bat # Build automation for Windows
├── Makefile # Build automation for Linux
├── README.md # Project documentation
- GCC (GNU Compiler Collection) for Linux or MinGW for Windows.
- Make and Batch utility.
- Basic C programming knowledge.
- Git: To clone the repository and manage version control.
- Text Editor: Any text editor or IDE like VSCode, Sublime Text, or Vim for editing code.
- Terminal/Command Prompt: Familiarity with using a terminal or command prompt to run commands.
git clone https://github.com/priyamaggarwal18/Lit-Version-Control-Simulation.git
cd Lit-Version-Control-Simulation
For Linux:
make run
For Windows:
.\build.bat
.\bin\lit.exe init
./bin/lit init
.\bin\lit.exe add file_location\file_name
./bin/lit add file_location\file_name
.\bin\lit.exe commit "Your Commit Message"
./bin/lit commit "Your Commit Message"
.\bin\lit.exe push
./bin/lit push
.\bin\lit.exe history
./bin/lit history
- stdio.h: For input and output operations such as
printf
,scanf
,fopen
, etc. - stdlib.h: For memory allocation, process control, conversions, and other utilities like
malloc
,free
,exit
, etc. - string.h: For string handling functions such as
strcpy
,strlen
,strcat
, etc. - time.h: For handling date and time operations (used for timestamps in commits).
- errno.h: For handling error codes.
- assert.h: For implementing assertions in test cases to validate conditions.
- dirent.h: For directory traversal on Linux and POSIX-compliant systems.
- sys/stat.h: For manipulating file and directory attributes on Linux and POSIX-compliant systems.
- direct.h: For handling directory operations on Windows.
- windows.h: For additional Windows-specific functions and API calls.
- unistd.h: For POSIX operating system API, providing access to the POSIX operating system API, including system calls and utility functions.
- sys/stat.h: For file status and permissions.
- fcntl.h: For file control operations, including locking files.
-
- Make: A build automation tool for Linux environments.
- MinGW (Minimalist GNU for Windows): A compiler system for Windows, necessary if you're compiling on a Windows platform.
These libraries ensure compatibility across both Windows and Linux environments, providing the necessary utilities to build, manage files, and interact with the operating system.
The build.bat
file is a Windows batch script that automates the process of compiling your project and building the executable. It creates necessary directories (bin
and obj
), compiles each source file into object files, and links them to produce the final executable (lit.exe
).
- Automates the build process on Windows.
- Handles directory creation if they do not already exist.
- Displays build success and includes ASCII art for a fun finish.
To use it, simply run:
build.bat
The Makefile automates the build process on Linux. It defines a series of commands to compile source files, link them into an executable, and clean up build artifacts. It also includes test targets to verify the correctness of your project.
- Automates compilation on Linux.
- Run tests with
make run
. - Note: The
make
utility may not be installed by default on some Linux distributions. You can install it using the following commands based on your distribution:
- Debian/Ubuntu-based systems:
sudo apt update sudo apt install make
Click on the image below to navigate to the demo working video of Lit:
As Lit evolves, a few key features are planned to make the version control system more robust and closer to basic Git functionality. Below are the planned future enhancements:
- Branching System: Implement a simple branching mechanism to create and switch between branches, enabling multiple development paths.
- File Status Tracking: Add the ability to check the status of files (e.g., modified, staged, or committed) within the repository.
- Basic Merge Functionality: Simulate merging changes from one branch to another with basic conflict detection and manual resolution.
These features will enhance Lit by providing more control over file changes and simplifying collaborative development workflows.