Git implementation using Golang
I am using git in a daily basics but know nothing about the internal data structures used by git. It took Linus a few weeks to implement git , how many months it will take me ? Will see...
- cat-file
- [o] checkout
- Change branch
- Change files content
- Secure unchanged files
- commit-tree
- hash-object
- init
- [o] log
- Regular log of commits
- Patch - show diff of each commit
- ls-tree
- merge - To consider
- rm
- index
- write-tree
- update-ref
- Diff
- Kong - cli parser
- Tablewriter - table output
- Git Config - to get your git user
The blobs are basically implemented in the same way they work in original git. Blob file contains two peaces of information
- Header
- Zipped data
Here is the format for blob file type length\x00zipped_data
where
- type - the object type followed by space (blob,tree etc)
- length - the length of unzipped data(without header)
- \x00 - null character
- zipped_data - zipped representation of original data(without header)
In order to implement staging area git uses Index file but original Index format is a complex binary file and it contains too much information. The Index file used by dzhigit
is a simple text file with a list of entries in the following format
Mode C_time M_time sha1-hash F_name
Where
- Mode - is a file mode(100644 - normal file,100755 - executable)
- C_time - file's creation time in unix
- M_time - file's last modification time in unix
- sha1-hash - file's hash generated by
dzhigit hash-object command
- F_name - file's name
- Let's introduce new reader that reads data from path as deserialized git object
- Need to add test cases for parsers
- Let's split logic from commands.go file into multiple files, each responsible for single command
- String() for time doesn't use timezone yet