32 lines
1.0 KiB
Markdown
32 lines
1.0 KiB
Markdown
- 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.
|