29 lines
1.1 KiB
Markdown
29 lines
1.1 KiB
Markdown
- read-tree: Extract tree from object
|
|
|
|
This command will take an OID of a tree and extract it to the working directory.
|
|
Kind of the opposite of `write-tree`.
|
|
|
|
I divided the implementation into a few layers:
|
|
|
|
`_iter_tree_entries` is a generator that will take an OID of a tree, tokenize it
|
|
line-by-line and yield the raw string values.
|
|
|
|
`get_tree` uses `_iter_tree_entries` to recursively parse a tree into a
|
|
dictionary.
|
|
|
|
`read_tree` uses `get_tree` to get the file OIDs and writes them into the
|
|
working directory.
|
|
|
|
Now we can actually save versions of the working directory! It's nothing like
|
|
proper version control, but we can see that a super basic flow is possible:
|
|
|
|
+ Imagine you work on some code and you want to save a version.
|
|
+ You run ```ugit write-tree```.
|
|
+ You remember that OID that was printed out (write it on a post-it note or
|
|
something :)).
|
|
+ Continue working and repeat steps 2 and 3 as necessary.
|
|
+ If you want to return to a previous version, use `ugit read-tree` to restore
|
|
it to the working directory.
|
|
|
|
Is it convenient to use? No. But it's just the beginning!
|