K23EJ6EJBFYC73TX5MMV7ZMI2GXVQJT6OQCGV56MXPQN4BLOQZ5AC
if err := commit.WriteTo(os.Stdout); err != nil {
printErrorAndExit("Error writing commit:", err)
}
stream.AddCommit(commit)
}
stream.ReverseCommits()
if err := stream.WriteTo(os.Stdout); err != nil {
printErrorAndExit("Error writing output stream:", err)
}
return nil
}
// A FastExportStream is an in-memory representation of a fast-export stream.
type FastExportStream struct {
Commits []Commit
marks int
}
func (f *FastExportStream) AddCommit(c Commit) {
if c.Mark == 0 {
f.marks++
c.Mark = f.marks
}
f.Commits = append(f.Commits, c)
}
func (f *FastExportStream) ReverseCommits() {
for i, j := 0, len(f.Commits)-1; j > i; i, j = i+1, j-1 {
f.Commits[i], f.Commits[j] = f.Commits[j], f.Commits[i]