summaryrefslogtreecommitdiff
path: root/cmd.go
diff options
context:
space:
mode:
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
+}