From 5e4f84f2ff741d545c489f730848b498c87f18f1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 29 Apr 2021 19:37:54 -0600 Subject: tag names v2 --- cmd_command.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd_command.go b/cmd_command.go index 8c6a20a..14fd2e9 100644 --- a/cmd_command.go +++ b/cmd_command.go @@ -160,9 +160,9 @@ func (CmdCommitEnd) fiCmdRead(fir fiReader) (Cmd, error) { panic("not reached") // // Hint: Use CmdReset to create a *lightweight* tag. type CmdTag struct { - RefName string + TagName string Mark int // optional; < 1 for non-use - Name string // optional + RefName string // optional; default is "refs/tags/"+TagName CommitIsh string OriginalOID string // optional Tagger Ident @@ -173,12 +173,12 @@ func (c CmdTag) fiCmdClass() cmdClass { return cmdClassCommand } func (c CmdTag) fiCmdWrite(fiw fiWriter) error { ez := &ezfiw{fiw: fiw} - ez.WriteLine("tag", c.RefName) + ez.WriteLine("tag", c.TagName) if c.Mark > 0 { ez.WriteMark(c.Mark) } - if c.Name != "" { - ez.WriteLine("name", c.Name) + if c.RefName != "" && c.RefName != "refs/tags/"+c.TagName { + ez.WriteLine("refname", c.RefName) } ez.WriteLine("from", c.CommitIsh) if c.OriginalOID != "" { @@ -194,8 +194,8 @@ func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) { ez := &ezfir{fir: fir} defer ez.Defer(&err) - // 'tag' SP LF - c := CmdTag{RefName: trimLinePrefix(ez.ReadLine(), "tag ")} + // 'tag' SP LF + c := CmdTag{TagName: trimLinePrefix(ez.ReadLine(), "tag ")} // mark? if strings.HasPrefix(ez.PeekLine(), "mark :") { @@ -203,9 +203,9 @@ func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) { ez.Errcheck(err) } - // ('name' SP LF)? - if strings.HasPrefix(ez.PeekLine(), "name ") { - c.Name = trimLinePrefix(ez.ReadLine(), "name ") + // ('refname' SP LF)? + if strings.HasPrefix(ez.PeekLine(), "refname ") { + c.RefName = trimLinePrefix(ez.ReadLine(), "refname ") } // 'from' SP LF -- cgit v1.2.3-54-g00ecf