diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2021-02-01 18:08:22 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2021-02-01 18:16:11 -0700 |
commit | 4ff0403e82e7de5e7840d487efce54626e4e24fa (patch) | |
tree | 240e1f47ff1051533f2e2147ed77a268befaf840 /cmd_command.go | |
parent | 3115a98bdf713ff0f0f1c7e471cf452a48e466e8 (diff) |
Bring up to git.git commit b8f50e5b60e2654fcbf5f72b682635ee2e624923
Diffstat (limited to 'cmd_command.go')
-rw-r--r-- | cmd_command.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cmd_command.go b/cmd_command.go index 9249e75..700e47d 100644 --- a/cmd_command.go +++ b/cmd_command.go @@ -305,6 +305,49 @@ func (CmdBlob) fiCmdRead(fir fiReader) (cmd Cmd, err error) { return } +// alias /////////////////////////////////////////////////////////////////////// + +// CmdAlias requests that the Backend record that a merk refers to a +// given object without first creating any new object. +type CmdAlias struct { + Mark int + CommitIsh string +} + +func (c CmdAlias) fiCmdClass() cmdClass { return cmdClassCommand } +func (c CmdAlias) fiCmdWrite(fiw fiWriter) error { + ez := &ezfiw{fiw: fiw} + ez.WriteLine("alias") + ez.WriteMark(c.Mark) + ez.WriteLine("to", c.CommitIsh) + return ez.err +} +func init() { parser_registerCmd("alias\n", CmdCheckpoint{}) } +func (CmdAlias) fiCmdRead(fir fiReader) (cmd Cmd, err error) { + ez := &ezfir{fir: fir} + defer func() { err = ez.Defer() }() + + // 'alias' LF + _ = ez.ReadLine() + c := CmdAlias{} + + // mark + if !strings.HasPrefix(ez.PeekLine(), "mark :") { + ez.Errcheck(errors.Errorf("alias: expected mark command: %v", 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())) + } + c.CommitIsh = trimLinePrefix(ez.ReadLine(), "to ") + + cmd = c + return +} + // checkpoint ////////////////////////////////////////////////////////////////// // CmdCheckpoint requests that the Backend flush already-sent data. |