pub fn create_tag(
db: &Db,
name: &str,
at_seq: u64,
message: Option<&str>,
) -> Result<TagRecord, Error>Expand description
Create an immutable tag at at_seq.
Refuses, naming itself each time:
- an invalid name (see
validate_ref_name); - a sequence that does not exist yet — a tag pointing into the future names nothing, and would silently become valid later, naming whatever happened to land there;
- a name already tagged at a DIFFERENT sequence, reporting the current target so the caller can see what they collided with;
- a name that was tagged and then deleted, reporting what it pointed at.
Re-creating the same name at the SAME sequence is idempotent success. The assertion the caller is making is already true, and tooling retries; an error there would be noise that teaches people to ignore this error class.
state_root is captured from Db::get_root when a root is already
persisted at at_seq, and left None otherwise. It is NOT computed here:
per create_root_at, a historical root is O(live state) plus a
version-chain walk per document, and hiding that behind tag is how an
operator learns the cost by waiting. None means “no root was taken here”,
and the caller can take one explicitly and re-tag at a new name.