diff options
Diffstat (limited to 'cmd_commit.go')
-rw-r--r-- | cmd_commit.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/cmd_commit.go b/cmd_commit.go index 83b9815..170c511 100644 --- a/cmd_commit.go +++ b/cmd_commit.go @@ -16,11 +16,10 @@ package libfastimport import ( - "fmt" "strconv" "strings" - "git.lukeshu.com/go/libfastimport/textproto" + "github.com/pkg/errors" ) // M /////////////////////////////////////////////////////////////////////////// @@ -33,8 +32,8 @@ import ( // To specify the full content of the file inline, use // FileModifyInline instead. type FileModify struct { - Mode textproto.Mode - Path textproto.Path + Mode Mode + Path Path DataRef string } @@ -52,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, fmt.Errorf("commit: malformed modify command: %v", line) + return nil, errors.Errorf("commit: malformed modify command: %v", line) } nMode, err := strconv.ParseUint(fields[0], 8, 18) @@ -61,7 +60,7 @@ func (FileModify) fiCmdRead(fir fiReader) (cmd Cmd, err error) { } ref := fields[1] - path := textproto.PathUnescape(fields[2]) + path := PathUnescape(fields[2]) if ref == "inline" { line, err = fir.ReadLine() @@ -73,13 +72,13 @@ func (FileModify) fiCmdRead(fir fiReader) (cmd Cmd, err error) { return nil, err } return FileModifyInline{ - Mode: textproto.Mode(nMode), + Mode: Mode(nMode), Path: path, Data: data, }, nil } else { return FileModify{ - Mode: textproto.Mode(nMode), + Mode: Mode(nMode), Path: path, DataRef: ref, }, nil @@ -94,8 +93,8 @@ func (FileModify) fiCmdRead(fir fiReader) (cmd Cmd, err error) { // To instead specify the content with a mark reference (":<idnum>") // or with a full 40-byte SHA-1, use FileModify instead. type FileModifyInline struct { - Mode textproto.Mode - Path textproto.Path + Mode Mode + Path Path Data string } @@ -113,7 +112,7 @@ func (FileModifyInline) fiCmdRead(fiReader) (Cmd, error) { panic("not reached") // FileDelete appears after a CmdCommit (and before a CmdCommitEnd), // and causes the CmdCommit to recursively remove a file or directory. type FileDelete struct { - Path textproto.Path + Path Path } func (o FileDelete) fiCmdClass() cmdClass { return cmdClassCommit } @@ -126,7 +125,7 @@ func (FileDelete) fiCmdRead(fir fiReader) (cmd Cmd, err error) { if err != nil { return nil, err } - return FileDelete{Path: textproto.PathUnescape(trimLinePrefix(line, "D "))}, nil + return FileDelete{Path: PathUnescape(trimLinePrefix(line, "D "))}, nil } // C /////////////////////////////////////////////////////////////////////////// @@ -135,8 +134,8 @@ func (FileDelete) fiCmdRead(fir fiReader) (cmd Cmd, err error) { // and causes the CmdCommit to recursively copy an existing file or // subdirectory to a different location. type FileCopy struct { - Src textproto.Path - Dst textproto.Path + Src Path + Dst Path } func (o FileCopy) fiCmdClass() cmdClass { return cmdClassCommit } @@ -218,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, fmt.Errorf("commit: malformed notemodify command: %v", line) + return nil, errors.Errorf("commit: malformed notemodify command: %v", line) } ref := str[:sp] |