Hi Andreas, you gave me a lot of new insight and keywords I can google (Junio as well!). Thanks a lot! On Fri, Aug 16, 2013 at 11:12 AM, Andreas Ericsson <ae@xxxxxx> wrote: > More or less, yes, but please don't confuse "directory tree" with "git > tree". They're not the same. A directory tree can contain multiple > levels of directories, whereas a git tree can only contain a list > of objects. The index (aka "staging area") represents a directory tree, but > when it gets stored on-disk a directory tree gets broken down into > as many git trees as is necessary. I was confusing it in a way, that I didn't even realize that it was confusion. I thought from the Git-Book chapter 9 that the index itself would store a git-tree reference, like a commit does. Therefore in my own git add implementation I always started with reading and writing git-trees without any cache in the middle. With a simple, flat index in the middle of course the whole problem becomes much simpler! Also after working through the man files of the plumbing commands you showed I can use that much better in my daily git usage. Can't thank you guys enough! I think I start my python-git from scratch again, now that I understand everything much better. For now I assume the following algorithms: a) git add path/to/file 1. read the index into a memory object (probably a dictionary like "index = { 'path/to/file' : (mode, sha1), ... }") 2. write a blob of path/to/file to the object store 3. update index["path/to/file"] with the new sha1 4. write updated index to filesystem b) git commit -m <msg> 1. read index to memory 2. recursively create memory git-tree objects top-down 3. write git-tree objects to object store recursively bottom-up, tracking the sha1 of child trees for parent trees 4. add root-sha1 and commit-msg to memory commit object (author, committer and so on can be added later) 5. write commit object to object store 6. update HEAD (branches will be added later) 7. clean index ("index = {}") 8. write empty index to filesystem Cheers Erik -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html