Implement Git by Yourself (2: Data provider)

1 Init

It doesn’t have magic in the init operation and just create .ugit and ugit\objects folder in the working directory. It also will delete existing folder if you run multi-times of init command.

if (this.fileSystem.Directory.Exists(this.GitDir)){    this.fileSystem.Directory.Delete(this.GitDir, true);}this.fileSystem.Directory.CreateDirectory(this.GitDir);this.fileSystem.Directory.CreateDirectory(Path.Join(this.GitDir, "objects"));

2 Object

Object setter and getter are back bones for a file database. In order to distinguish different files, we have to add a tag for them. The GetObject and HashObject methods signature are

byte[] GetObject(string oid, string expected="blob");
string HashObject(byte[] data, string type="blob");

3 Ref

The ref stands for reference. In ugit it has three kinds of references:

  • branch: .ugit\refs\heads\<branch-name>
  • tag: .ugit\refs\tags\<tag-name>
  • HEAD: ugit\HEAD

4 Index

Comparing with other CVS, ugit has staging area.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store