summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2021-02-01 15:55:35 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2021-02-01 17:24:30 -0700
commit41a084d01e7be44b5a7bc0a30438e5f64ac41e33 (patch)
treeafd686dad854e2bfd40b0f178ab330372e25a0de
parent01ed9a06b20d32b148446d715d6e1beb3050d069 (diff)
Bring up to git.git commit a965bb31166d04f3e5c8f7a93569fb73f9a9d749
-rw-r--r--cmd_command.go53
1 files changed, 40 insertions, 13 deletions
diff --git a/cmd_command.go b/cmd_command.go
index a958b60..e68a3b1 100644
--- a/cmd_command.go
+++ b/cmd_command.go
@@ -33,13 +33,14 @@ import (
// terminated by a CmdCommitEnd command. It is not nescessary to
// manually emit a CmdCommitEnd when writing to a Backend.
type CmdCommit struct {
- Ref string
- Mark int // optional; < 1 for non-use
- Author *Ident
- Committer Ident
- Msg string
- From string
- Merge []string
+ Ref string
+ Mark int // optional; < 1 for non-use
+ OriginalOID string // optional
+ Author *Ident
+ Committer Ident
+ Msg string
+ From string
+ Merge []string
}
func (c CmdCommit) fiCmdClass() cmdClass { return cmdClassCommand }
@@ -50,6 +51,9 @@ func (c CmdCommit) fiCmdWrite(fiw fiWriter) error {
if c.Mark > 0 {
ez.WriteMark(c.Mark)
}
+ if c.OriginalOID != "" {
+ ez.WriteLine("original-oid", c.OriginalOID)
+ }
if c.Author != nil {
ez.WriteLine("author", *c.Author)
}
@@ -78,6 +82,11 @@ func (CmdCommit) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
ez.Errcheck(err)
}
+ // original-oid?
+ if strings.HasPrefix(ez.PeekLine(), "original-oid ") {
+ c.OriginalOID = trimLinePrefix(ez.ReadLine(), "original-oid ")
+ }
+
// ('author' (SP <name>)? SP LT <email> GT SP <when> LF)?
if strings.HasPrefix(ez.PeekLine(), "author ") {
author, err := ParseIdent(trimLinePrefix(ez.ReadLine(), "author "))
@@ -130,10 +139,11 @@ func (CmdCommitEnd) fiCmdRead(fir fiReader) (Cmd, error) { panic("not reached")
//
// Hint: Use CmdReset to create a *lightweight* tag.
type CmdTag struct {
- RefName string
- CommitIsh string
- Tagger Ident
- Data string
+ RefName string
+ CommitIsh string
+ OriginalOID string // optional
+ Tagger Ident
+ Data string
}
func (c CmdTag) fiCmdClass() cmdClass { return cmdClassCommand }
@@ -142,6 +152,9 @@ func (c CmdTag) fiCmdWrite(fiw fiWriter) error {
ez.WriteLine("tag", c.RefName)
ez.WriteLine("from", c.CommitIsh)
+ if c.OriginalOID != "" {
+ ez.WriteLine("original-oid", c.OriginalOID)
+ }
ez.WriteLine("tagger", c.Tagger)
ez.WriteData(c.Data)
@@ -161,6 +174,11 @@ func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
}
c.CommitIsh = trimLinePrefix(ez.ReadLine(), "from ")
+ // original-oid?
+ if strings.HasPrefix(ez.PeekLine(), "original-oid ") {
+ c.OriginalOID = trimLinePrefix(ez.ReadLine(), "original-oid ")
+ }
+
// '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()))
@@ -221,8 +239,9 @@ func (CmdReset) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
// given), or by pre-calculating the Git SHA-1 (though this is
// needlessly difficult, just specify a Mark).
type CmdBlob struct {
- Mark int // optional
- Data string
+ Mark int // optional
+ OriginalOID string // optional
+ Data string
}
func (c CmdBlob) fiCmdClass() cmdClass { return cmdClassCommand }
@@ -233,6 +252,9 @@ func (c CmdBlob) fiCmdWrite(fiw fiWriter) error {
if c.Mark > 0 {
ez.WriteMark(c.Mark)
}
+ if c.OriginalOID != "" {
+ ez.WriteLine("original-oid", c.OriginalOID)
+ }
ez.WriteData(c.Data)
return ez.err
@@ -251,6 +273,11 @@ func (CmdBlob) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
c.Mark, err = strconv.Atoi(trimLinePrefix(ez.ReadLine(), "mark :"))
}
+ // original-oid?
+ if strings.HasPrefix(ez.PeekLine(), "original-oid ") {
+ c.OriginalOID = trimLinePrefix(ez.ReadLine(), "original-oid ")
+ }
+
// data
c.Data, err = parse_data(ez.ReadLine())
ez.Errcheck(err)