From 01ed9a06b20d32b148446d715d6e1beb3050d069 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 Feb 2021 15:55:03 -0700 Subject: Tidy up cmdClass --- cmd_comment.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'cmd_comment.go') diff --git a/cmd_comment.go b/cmd_comment.go index c0325b4..2124c8e 100644 --- a/cmd_comment.go +++ b/cmd_comment.go @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Luke Shumaker +// Copyright (C) 2017-2018, 2021 Luke Shumaker // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -22,6 +22,10 @@ import ( "github.com/pkg/errors" ) +// This file deals with comments, and with commands for which the +// specification says (or said) that the command "can be used anywhere +// in the stream that comments are accepted". + // comment ///////////////////////////////////////////////////////////////////// // CmdComment is a comment line; not a real command. @@ -105,19 +109,17 @@ type CmdLs struct { Path Path } -// If you're thinking "but wait, parser_registerCmd will see CmdLs as -// cmdClassCommit, not cmdClassComment, that means it won't be allowed -// embedded inside other commands! (while still allowing it both -// inside and outside of a commit)", you're absolutely correct. -// That's the desired behavior. It's a happy accident that the little -// fiCmdClass hack works out that way, instead of having to add even -// more complexity. - func (c CmdLs) fiCmdClass() cmdClass { + // As of git v2.21, the docs say this is cmdClassComment, but + // the actual code disagrees. if c.DataRef == "" { - return cmdClassCommit + // Yeah, this will give slightly misleading info to + // parser_registerCmd(), but that's OK, + // parser_registerCmd() only really cares about the + // cmdClassInCommand bit. + return cmdClassInCommit } - return cmdClassComment + return cmdClassCommand | cmdClassInCommit } func (c CmdLs) fiCmdWrite(fiw fiWriter) error { if c.DataRef == "" { -- cgit v1.2.3