From 4ff0403e82e7de5e7840d487efce54626e4e24fa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 Feb 2021 18:08:22 -0700 Subject: Bring up to git.git commit b8f50e5b60e2654fcbf5f72b682635ee2e624923 --- cmd.go | 2 +- cmd_command.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/cmd.go b/cmd.go index 7b7e122..e4aa43e 100644 --- a/cmd.go +++ b/cmd.go @@ -27,7 +27,7 @@ // A program can read commands from a frontend by wrapping the // appropriate io.Reader with a Frontend object. // -// This is up-to-date with full syntax supported by git v2.23.0. +// This is up-to-date with full syntax supported by git v2.24.0. package libfastimport type fiReader interface { 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