Skip to content

yacine204/cit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cit

A custom version control system from scratch. Tracks file changes and creates commits with diffs.

how it works

cit tracks changes using a custom N-ary tree structure (Rose tree):

  • internal nodesstruct tree (directories)
  • leaf nodesstruct node (files)
  • each node stores its full content, a hash, and a diff against the previous commit

commits

  • commits are stored as text files in .cit/ directory with format: <message>_<timestamp>.cit
  • each commit contains the entire file tree snapshot with:
    • changes: diff showing what was added (+) or removed (-) from the previous commit
    • context: full file content for that commit
  • commits form a linked list where each commit has a reference to its parent

build and run

Compile:

gcc -o main main.c src/tree.c src/commit.c src/hash.c

Create a commit:

./main . commit "your commit message"

commit file format

See examples/commit_diff.txt for a detailed example of what a commit file looks like. (or u can directly check the binaries in .cit/ folder, theyre readable txt format).

Commit files are human-readable text with:

  • ##commit header: metadata (timestamp, tree count, node count)
  • ##node sections: one for each file
  • ##changes: line-by-line diff from previous commit
  • ##context: full file content

what it tracks

  • all files in the repository (excluding .cit/ and .git/)
  • line-by-line changes between commits
  • full file history in each commit snapshot

TODO

  • cli loop
  • diff
  • checkout
  • branch & switch

About

what happens when you build a version control system in C without looking at how git does it

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages