This is a creation in Article, where the information may have evolved or changed.
Everybody's going to turn into someone they hate.
Git caches the current directory through binary files .git/index
, enabling fast exchange of working directory and warehouse data. Git's cache is stored in the index file, why not the cache, it's strange.
The current directory cache for Git should at least meet the following features:
Caches can be generated at any time based on the current warehouse (HEAD state).
The cache does not always conform to the warehouse state.
The cached data format is fixed and can be parsed by multiple Git commands over time.
Git Index file format
The current directory cache file is responsible for exchanging and transferring data between multiple Git commands, and its file format is also important.
Git Index (version 2) is stored in binary mode with the following storage:
The detailed format can be found here in Git index format.
See Linus at the beginning of the design of the version number, for the future index of the file format changes to provide convenience, it is worth our reference.
In addition to the Flags/size/path NAME/SHA1 required by Git object, each index phase also stores the stat 2 information. The index file is also SHA1 encoded to verify that the data is correct or not.
In addition, the index file is arranged and implemented with as little space as possible and stored in a binary way. Saving resources is the basic quality of Daniel!
The DIT option is implemented using the version 2 index file format.
By parsing the git index file into the GIT basic data structure, Git's prototype is available. For the next few days, I'll implement a primary version of the Dit system, because both the design and the content mimic git massively, so you'll use the same License as git to open source.
I wrote a simple version of the Git Index parsing tool and went to Github to view it.
Zddhub produced by Wood B-word
Number: Zddnotes
Just for fun!
Article only write to yourself, if you also like, Welcome to scan the following two-dimensional code attention OH ~