Add change 12 instructions
This commit is contained in:
parent
2f8545d48e
commit
6f5fe864a9
28
how_to/Change_12.md
Normal file
28
how_to/Change_12.md
Normal file
@ -0,0 +1,28 @@
|
||||
- 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!
|
Loading…
Reference in New Issue
Block a user