As the title suggest, is the value based on the content of all tree objects(recursively) inside?
Namely, can I regard two tree objects as the exactly same file tree (including all the subdirectories and files) if they have the same hash value?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can see some rough details about what is used to calculate the tree SHA here.
Further information about the binary format that the tree is stored in can be found here.
The actual SHA that is used is just the SHA of the buffer described in that detailed version.
The key points to take home is that the SHA is dependent on the filenames of all contained objects or trees, their SHAs and their permissions. Change any of those and you change the SHA. If two trees have the same SHAs then all those components must match (excluding the possibility of collisions as they’re nigh on impossible).