summaryrefslogtreecommitdiff
path: root/cmd.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2021-02-01 15:55:03 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2021-02-01 17:23:29 -0700
commit01ed9a06b20d32b148446d715d6e1beb3050d069 (patch)
tree8b0ef328859804e7b6bafb8f1495817fc31bb756 /cmd.go
parent328f9cc1ac0ebee9499dc8d50bd84f71897d4df7 (diff)
Tidy up cmdClass
Diffstat (limited to 'cmd.go')
-rw-r--r--cmd.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd.go b/cmd.go
index 1665081..d1358a8 100644
--- a/cmd.go
+++ b/cmd.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2018 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2017-2018, 2021 Luke Shumaker <lukeshu@lukeshu.com>
//
// 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
@@ -41,10 +41,11 @@ type fiWriter interface {
type cmdClass int
const (
- cmdClassCommand cmdClass = 1 // may be a top-level command
- cmdClassCommit cmdClass = 2 // may be used within in a commit
+ cmdClassCommand cmdClass = 1 << iota // can be a top-level command
+ cmdClassInCommit // can be used within in a commit
+ cmdClassInCommand // can be used in-between lines of another multi-line command
- cmdClassComment cmdClass = cmdClassCommand | cmdClassCommit
+ cmdClassComment = cmdClassCommand | cmdClassInCommit | cmdClassInCommand // "can be used anywhere in the stream that comments are accepted"
)
// Cmd is a command that may be found in a fast-import stream.
@@ -53,3 +54,7 @@ type Cmd interface {
fiCmdWrite(fiWriter) error
fiCmdClass() cmdClass
}
+
+func cmdIs(cmd Cmd, class cmdClass) bool {
+ return cmd.fiCmdClass()&class != 0
+}