ZIT development log
ZIT development log
Thanks for the great tutorial: https://www.leshenko.net/p/ugit
Thanks again Nikita!
Resource
I found some good reference material, and I put them under the ./doc directory.
Besides, the follow links maybe help you too.
- Nick Butler this post is short but enough to help you have a higher level to understand diff
- jcoglan this posts make a detail description about the diff.
- visualize if you wanna have a debugger or visualization about diff algorithm, this will be a good choice.
If you feel interested about this project, you can post your idea on the discussion or just contact me with email.
Usage
- alias zit='java -jar ../zit-1.0-SNAPSHOT-shaded.jar'alias the zit executable file.- windows could set here C:\Program Files\Git\etc\profile.d\aliases.sh
 
- windows could set here 
- zit initinit directory- .zitwhich include- objectssubdirectory, init index file which would be treated as stage area, and set- mainbranch as default to prevent detached head- the default HEAD file content is ref: ref/heads/main
 
- the default HEAD file content is 
- zit hash-object file- Get the path of the file to store.
- Read the file.
- Hash the content of the file using SHA-1.
- Store the file under .ugit/objects/{the SHA-1 hash}.
 
- zit cat-file hash [object|tree|commit|...type]print the file content
- zit write-treegenerate the tree which is the whole description of the repository.- after finished addcommand, it will write tree which is generated by index file
 
- after finished 
- zit read-tree hash- pay attention!this action will delete all existing stuff before reading.
- So you can use cat-fileto find which tree is theroot, and the logs ofwrite-treealso help you find all the trees.
 
- Although - write-treecan save version, but it does not take any context information, so will need to develop- zit commit -m "message"command.- you can use cat-file hash commit-idto check your commit content
- HEADwill record your commit with its parent.
 
- you can use 
- Just enjoy commit and the type - logto see the logs.
- Now we get the first point: - checkout. Pick a commit id from the- logand checkout whether things as expected.- [fixed with getBytes(Charsets.UTF-8)] find bug todo: chinese file or dir name got messy code
- args could be head alias, hash and ref(branch, tags, HEAD…)
 
- tagwill alias commit id, and at this time, you will get first inner core concept.- git-ref the official post will help you learn some basic knowledge about the git.
 
- todo: - zit lggraph feature with Graphviz
- zit branch name [id]so familiar.- Every ref under refs/heads will be treated as a branch.
- file content still just commit id, by default it is the head point
 
- zit showwill use diff show changes detail while status only show simply changes info.
- zit addwill add paths which could be file or directory into stage file:- .zit/index.
- zit commitwill call- write treeand update head pointer to the commit id.- first time it will create default branch: mainand will rewrite the HEAD file content to the commit id
- the merge HEAD will be deleted and leave the message into commit message
 
- first time it will create default branch: 
- zit statusthis command will tell you what is the situation you are in now.- if you are not detached HEAD, it will log your current HEAD pointed branch first,
- after that, if you are working in merge, it will log the merge hash id,
- then it will log changes to be committed which will diff head tree to index(stage items),
- finally, it will log changes not staged for the next commit which diff index(stage) to work tree.
 
- zit diffthe default diff algorithm is myers diff without linear space refinement optimized
- zit resetjust change head to the current commit, the difference between it and- checkoutis the // todo
- zit mergewill check if the merge base equals the head, it will use fast-forward to merge- if fast-forward work, it will be no need to commit
- if not work, we will use diff3 merge to merge the merge base, head tree, other tree
- pay attention: diff3 will leave merge_head in the zit root directory and that means you need to commit manually.
- zit merge-baseis used to help the merge command find the first common parent commit of the commits which will be merged. But you also can use this command to do debug task.
 
- zit fetch,- zit pushthese two combined commands are used to download or upload objects and update the ref.
Summary
UPDATED 2021.02.21
- implemented the diff(myers diff but without linear space optimized) and merge algorithms(simple diff3) instead of using unix tools. 
- Ugituse some cool- Pythoniccode while zit trying to make code easy understood for the other language developer.
TODO
- git hash-object todo. When real Git stores objects it does a few extra things, such as writing the size of the object to the file as well, compressing them and dividing the objects into 256 directories. This is done to avoid having directories with huge number of files, which can hurt performance.
- Title: ZIT development log
- Author: ReZero
- Created at : 2021-02-10 16:41:00
- Updated at : 2025-05-26 05:53:22
- Link: https://rezeros.github.io/2021/02/10/zit/
- License: This work is licensed under CC BY-NC-SA 4.0.