dzhigit

command module
v0.0.0-...-5f9f762 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

README

dzhigit

Git implementation using Golang

Motivation

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...

TODO

  1. cat-file
  2. [o] checkout
    1. Change branch
    2. Change files content
    3. Secure unchanged files
  3. commit-tree
  4. hash-object
  5. init
  6. [o] log
    1. Regular log of commits
    2. Patch - show diff of each commit
  7. ls-tree
  8. merge - To consider
  9. rm
  10. index
  11. write-tree
  12. update-ref
  13. Diff

Dependencies

  1. Kong - cli parser
  2. Tablewriter - table output
  3. Git Config - to get your git user

How it works

Blobs

The blobs are basically implemented in the same way they work in original git. Blob file contains two peaces of information

  1. Header
  2. Zipped data

Here is the format for blob file type length\x00zipped_data where

  1. type - the object type followed by space (blob,tree etc)
  2. length - the length of unzipped data(without header)
  3. \x00 - null character
  4. zipped_data - zipped representation of original data(without header)
Index file

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

  1. Mode - is a file mode(100644 - normal file,100755 - executable)
  2. C_time - file's creation time in unix
  3. M_time - file's last modification time in unix
  4. sha1-hash - file's hash generated by dzhigit hash-object command
  5. F_name - file's name

Working On

  1. Let's introduce new reader that reads data from path as deserialized git object
  2. Need to add test cases for parsers
  3. Let's split logic from commands.go file into multiple files, each responsible for single command
  4. String() for time doesn't use timezone yet

Resources

  1. Git magic
  2. Write yourself a Git!

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL