summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2021-02-22 22:05:53 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2021-02-22 23:06:37 -0700
commit5002c653d53b7ef21a91f889a17f4f2ab52596d8 (patch)
treec056071bf6fd268228ab28efb2943bd4722e4079
parent89f98d13da60b4768f3f2e61594d027b009b920d (diff)
tree-wide: Use %q instead of %v as appropriate in error messages
-rw-r--r--cmd_command.go10
-rw-r--r--cmd_incommit.go4
-rw-r--r--types.go10
-rw-r--r--util.go8
4 files changed, 16 insertions, 16 deletions
diff --git a/cmd_command.go b/cmd_command.go
index 32292d3..f31860b 100644
--- a/cmd_command.go
+++ b/cmd_command.go
@@ -100,7 +100,7 @@ func (CmdCommit) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
// 'committer' (SP <name>)? SP LT <email> GT SP <when> LF
if !strings.HasPrefix(ez.PeekLine(), "committer ") {
- ez.Errcheck(errors.Errorf("commit: expected committer command: %v", ez.ReadLine()))
+ ez.Errcheck(errors.Errorf("commit: expected committer command: %q", ez.ReadLine()))
}
c.Committer, err = ParseIdent(trimLinePrefix(ez.ReadLine(), "committer "))
ez.Errcheck(err)
@@ -189,7 +189,7 @@ func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
// 'from' SP <commit-ish> LF
if !strings.HasPrefix(ez.PeekLine(), "from ") {
- ez.Errcheck(errors.Errorf("tag: expected from command: %v", ez.ReadLine()))
+ ez.Errcheck(errors.Errorf("tag: expected from command: %q", ez.ReadLine()))
}
c.CommitIsh = trimLinePrefix(ez.ReadLine(), "from ")
@@ -200,7 +200,7 @@ func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
// 'tagger' (SP <name>)? SP LT <email> GT SP <when> LF
if !strings.HasPrefix(ez.PeekLine(), "tagger ") {
- ez.Errcheck(errors.Errorf("tag: expected tagger command: %v", ez.ReadLine()))
+ ez.Errcheck(errors.Errorf("tag: expected tagger command: %q", ez.ReadLine()))
}
c.Tagger, err = ParseIdent(trimLinePrefix(ez.ReadLine(), "tagger "))
ez.Errcheck(err)
@@ -333,14 +333,14 @@ func (CmdAlias) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
// mark
if !strings.HasPrefix(ez.PeekLine(), "mark :") {
- ez.Errcheck(errors.Errorf("alias: expected mark command: %v", ez.ReadLine()))
+ ez.Errcheck(errors.Errorf("alias: expected mark command: %q", ez.ReadLine()))
}
c.Mark, err = strconv.Atoi(trimLinePrefix(ez.ReadLine(), "mark :"))
ez.Errcheck(err)
// 'to' SP <commit-ish LF
if !strings.HasPrefix(ez.PeekLine(), "to ") {
- ez.Errcheck(errors.Errorf("alias: expected to command: %v", ez.ReadLine()))
+ ez.Errcheck(errors.Errorf("alias: expected to command: %q", ez.ReadLine()))
}
c.CommitIsh = trimLinePrefix(ez.ReadLine(), "to ")
diff --git a/cmd_incommit.go b/cmd_incommit.go
index f58e59f..c8ae15f 100644
--- a/cmd_incommit.go
+++ b/cmd_incommit.go
@@ -51,7 +51,7 @@ func (FileModify) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
str := trimLinePrefix(line, "M ")
fields := strings.SplitN(str, " ", 3)
if len(fields) != 3 {
- return nil, errors.Errorf("commit: malformed modify command: %v", line)
+ return nil, errors.Errorf("commit: malformed modify command: %q", line)
}
nMode, err := strconv.ParseUint(fields[0], 8, 18)
@@ -217,7 +217,7 @@ func (NoteModify) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
str := trimLinePrefix(line, "N ")
sp := strings.IndexByte(str, ' ')
if sp < 0 {
- return nil, errors.Errorf("commit: malformed notemodify command: %v", line)
+ return nil, errors.Errorf("commit: malformed notemodify command: %q", line)
}
ref := str[:sp]
diff --git a/types.go b/types.go
index f3b7eed..a56f45d 100644
--- a/types.go
+++ b/types.go
@@ -64,27 +64,27 @@ func ParseIdent(str string) (Ident, error) {
ret := Ident{}
lt := strings.IndexAny(str, "<>")
if lt < 0 || str[lt] != '<' {
- return ret, errors.Errorf("Missing < in ident string: %v", str)
+ return ret, errors.Errorf("Missing < in ident string: %q", str)
}
if lt > 0 {
if str[lt-1] != ' ' {
- return ret, errors.Errorf("Missing space before < in ident string: %v", str)
+ return ret, errors.Errorf("Missing space before < in ident string: %q", str)
}
ret.Name = str[:lt-1]
}
gt := lt + 1 + strings.IndexAny(str[lt+1:], "<>")
if gt < lt+1 || str[gt] != '>' {
- return ret, errors.Errorf("Missing > in ident string: %v", str)
+ return ret, errors.Errorf("Missing > in ident string: %q", str)
}
if str[gt+1] != ' ' {
- return ret, errors.Errorf("Missing space after > in ident string: %v", str)
+ return ret, errors.Errorf("Missing space after > in ident string: %q", str)
}
ret.Email = str[lt+1 : gt]
strWhen := str[gt+2:]
sp := strings.IndexByte(strWhen, ' ')
if sp < 0 {
- return ret, errors.Errorf("missing time zone in when: %v", str)
+ return ret, errors.Errorf("missing time zone in when: %q", str)
}
sec, err := strconv.ParseInt(strWhen[:sp], 10, 64)
if err != nil {
diff --git a/util.go b/util.go
index 4ca60e9..544818e 100644
--- a/util.go
+++ b/util.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2017 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2017, 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
@@ -35,19 +35,19 @@ func trimLinePrefix(line string, prefix string) string {
func parse_data(line string) (data string, err error) {
nl := strings.IndexByte(line, '\n')
if nl < 0 {
- return "", errors.Errorf("data: expected newline: %v", data)
+ return "", errors.Errorf("data: expected newline: %q", data)
}
head := line[:nl+1]
rest := line[nl+1:]
if !strings.HasPrefix(head, "data ") {
- return "", errors.Errorf("data: could not parse: %v", data)
+ return "", errors.Errorf("data: could not parse: %q", data)
}
if strings.HasPrefix(head, "data <<") {
// Delimited format
delim := trimLinePrefix(head, "data <<")
suffix := "\n" + delim + "\n"
if !strings.HasSuffix(rest, suffix) {
- return "", errors.Errorf("data: did not find suffix: %v", suffix)
+ return "", errors.Errorf("data: did not find suffix: %q", suffix)
}
data = strings.TrimSuffix(rest, suffix)
} else {