Lone Nine Swords (0x03)-Current directory Cache Chapter

Source: Internet
Author: User
Tags sha1 git commands
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:

    1. Caches can be generated at any time based on the current warehouse (HEAD state).

    2. The cache does not always conform to the warehouse state.

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.