Add change 21 instructions

This commit is contained in:
David Doblas Jiménez 2024-04-12 17:18:48 +02:00
parent 6797bcfabe
commit cb8e744794

23
how_to/Change_21.md Normal file
View File

@ -0,0 +1,23 @@
- tag: Generalize HEAD to refs
As part of implementing `tag`, we'll generalize the way we handle HEAD. If you
think about it, HEAD and tags are similar. They are both ways for ugit to attach
a name to an OID. In case of HEAD, the name is hardcoded by ugit; in case of
tags, the name will be provided by the user. It makes sense to handle them
similarly in *data.py*.
In *data.py*, let's extend the function `set_HEAD` and `get_HEAD` to
`update_ref` and `get_ref`. "Ref" is a short for reference, and that's the name
Git uses. The function will now accept the name of the ref and write/read it as
a file under *.ugit* directory. Logically, a ref is a named pointer to an object.
The important change is in *data.py*. The rest of the changes just rename some
functions:
```
- get_HEAD() -> get_ref('HEAD')
- set_HEAD(oid) -> update_ref('HEAD', oid)
```
Note that we didn't change any behaviour of ugit here, this is purely
refactoring.