summaryrefslogtreecommitdiff
path: root/cmd_comment.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd_comment.go')
-rw-r--r--cmd_comment.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/cmd_comment.go b/cmd_comment.go
index 684c92b..3e50b9a 100644
--- a/cmd_comment.go
+++ b/cmd_comment.go
@@ -33,7 +33,7 @@ type CmdComment struct {
Comment string
}
-func (c CmdComment) fiCmdClass() cmdClass { return cmdClassComment }
+func (c CmdComment) fiCmdClass(_ fiReaderState) cmdClass { return cmdClassComment }
func (c CmdComment) fiCmdWrite(fiw fiWriter) error {
return fiw.WriteLine("#" + c.Comment)
}
@@ -55,12 +55,15 @@ type CmdGetMark struct {
Mark int
}
-func (c CmdGetMark) fiCmdClass() cmdClass {
+func (c CmdGetMark) fiCmdClass(fir fiReaderState) cmdClass {
// Prior to git v2.22.0 this was 'cmdClassComment', but in
// v2.22.0 it was changed to a stricter
// 'cmdClassCommand|cmdClassInCommit'. I want to have better
// backward compatibility, so I'm keeping it as
// 'cmdClassComment'.
+ if c.Mark == fir.GetCommandMark() {
+ return cmdClassCommand
+ }
return cmdClassComment
}
func (c CmdGetMark) fiCmdWrite(fiw fiWriter) error {
@@ -90,13 +93,19 @@ type CmdCatBlob struct {
DataRef string
}
-func (c CmdCatBlob) fiCmdClass() cmdClass {
+func (c CmdCatBlob) fiCmdClass(fir fiReaderState) cmdClass {
// Prior to git v2.22.0 this was 'cmdClassComment', but in
// v2.22.0 it was changed to a stricter
// 'cmdClassCommand|cmdClassInCommit|cmdClassInFileModify'. I
// don't want to implement cmdClassInFileModify for just this
// one command, and also I want to have better backward
// compatibility; so I'm keeping it as 'cmdClassComment'.
+ if strings.HasPrefix(c.DataRef, ":") && fir.GetCommandMark() > 0 {
+ mark, _ := strconv.Atoi(c.DataRef[1:])
+ if mark == fir.GetCommandMark() {
+ return cmdClassCommand
+ }
+ }
return cmdClassComment
}
func (c CmdCatBlob) fiCmdWrite(fiw fiWriter) error {
@@ -124,7 +133,7 @@ type CmdLs struct {
Path Path
}
-func (c CmdLs) fiCmdClass() cmdClass {
+func (c CmdLs) fiCmdClass(fir fiReaderState) cmdClass {
// Prior to git v2.22.0 the docs said 'ls' was allowed
// anywhere a comment was allowed, but that was never really
// true, and in v2.22.0 the docs were updated to match the
@@ -136,6 +145,12 @@ func (c CmdLs) fiCmdClass() cmdClass {
// cmdClassInCommand bit.
return cmdClassInCommit
}
+ if strings.HasPrefix(c.DataRef, ":") && fir.GetCommandMark() > 0 {
+ mark, _ := strconv.Atoi(c.DataRef[1:])
+ if mark == fir.GetCommandMark() {
+ return cmdClassCommand
+ }
+ }
return cmdClassCommand | cmdClassInCommit
}
func (c CmdLs) fiCmdWrite(fiw fiWriter) error {