Add change 14 to instructions

This commit is contained in:
David Doblas Jiménez 2024-03-11 19:28:36 +01:00
parent c72370f930
commit 2c940abd1d

31
how_to/Change_14.md Normal file
View File

@ -0,0 +1,31 @@
- commit: Create commit
So far we were able to save versions of a directory (with `write-tree`), but
without any additional context. In reality, when we save a snapshot we would
like to attach data such as:
+ Message describing it
+ When the snapshot was created
+ Who created the snapshot
+ ...
We will create a new type of object called a "commit" that will store all this
information. A commit will just be a text file stored in the object database
with the type of `'commit'`.
The first lines in the commit will be key-values, then an empty line will mark
the end of the key-values and then the commit message will follow. Like this:
```
tree 5e550586c91fce59e0006799e0d46b3948f05693
author Nikita Leshenko
time 2019-09-14T09:31:09+00:00
This is the commit message!
```
For now we'll just write the "tree" key and the commit message to the commit
object.
We will create a new `ugit commit` command that will accept a commit message,
snapshot the current directory using `ugit write-tree` and save the resulting
object.