P2B4ZSO5YWG73KTDPO7KX5JNRNFDKF3UZEOJNGN22JRMAWQXFCSQC
}
if changeIndex > 0 {
if _, err := exec.Command("pijul", "unrecord", changes[changeIndex-1].Hash).Output(); err != nil {
printErrorAndExit("Error unrecording change "+changes[changeIndex-1].Hash+":", err)
}
if _, err := exec.Command("pijul", "reset").Output(); err != nil {
printErrorAndExit("Error from pijul reset:", err)
}
// To specify the content for the commit, we remove everything
// and then add back in all the files that are present after the change.
commit.DeleteAll = true
listing, err := exec.Command("pijul", "list").Output()
if err != nil {
printErrorAndExit("Error from pijul list:", err)
}
for _, f := range strings.Split(string(listing), "\n") {
if f == "" {
continue
}
info, err := os.Stat(f)
if err != nil {
printErrorAndExit("Error from Stat:", err)
}
if info.IsDir() {
continue
}
data, err := os.ReadFile(f)
if err != nil {
printErrorAndExit("Error reading "+f+":", err)
}
b := stream.AddBlob(data)
commit.Modifications = append(commit.Modifications, FileModify{Blob: b, Path: f})
}
type Blob struct {
Mark int
Data []byte
}
func (b Blob) WriteTo(w io.Writer) error {
if _, err := fmt.Fprintln(w, "blob"); err != nil {
return err
}
if b.Mark != 0 {
if _, err := fmt.Fprintf(w, "mark :%d\n", b.Mark); err != nil {
return err
}
}
if _, err := fmt.Fprintln(w, "data", len(b.Data)); err != nil {
return err
}
if _, err := w.Write(b.Data); err != nil {
return err
}
if _, err := fmt.Fprintln(w); err != nil {
return err
}
return nil
}