Files
DIY_GIT_in_Python/how_to/Change_08.md
2024-02-26 18:58:52 +01:00

1.1 KiB
Raw Blame History

  • write-tree: List files

The next command is write-tree. This command will take the current working directory and store it to the object database. If hash-object was for storing an individual file, then write-tree is for storing a whole directory.

Like hash-object, write-tree is going to give us an OID after its done and well be able to use the OID in order to retrieve the directory at a later time.

In Gits lingo a “tree” means a directory.

Well get into the details in later changes, in this change well only prepare the code around the feature:

  • Create a write-tree CLI command

  • Create a write_tree() function in base module. Why in base module and not in data module? Because write_tree() is not going to write to disk directly but use the object database provided by data to store the directory. Hence it belongs to the higher-level base module.

  • Add code to write_tree() to print a directory recursively. For now nothing is written anywhere, but we just coded the boilerplate to recursively scan a directory.

We continue in the next change.