Tag check

pmeunier
Dec 17, 2021, 9:57 AM
FDEVV5NGUMTEULP25EFYFZEVICWYLGV7XMED25PNKD36DL4NA46AC

Dependencies

  • [2] IQWG3UP4 Fixing a bug in tag restore
  • [3] L3RCAPPK Add --repository to tag commands
  • [4] G6UIBL6U Cleaner error handling for tag deserialization
  • [5] FZ7MXL3B Allow to use short tag hashes
  • [6] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [7] ZDK3GNDB Tag transactions (including a massive refactoring of errors)
  • [8] 5OGOE4VW Store the current channel in the pristine
  • [9] AAXP2534 Tags: completing the subcommand
  • [10] QL6K2ZM3 Tags

Change contents

  • replacement in pijul/src/commands/tag.rs at line 104
    [5.2655][5.2655:2764]()
    let mut tag_path = repo.path.join(libpijul::DOT_DIR);
    tag_path.push("tags");
    [5.2655]
    [5.2764]
    let mut tag_path = repo.changes_dir.clone();
  • replacement in pijul/src/commands/tag.rs at line 108
    [5.2872][5.2872:2911]()
    temp_path.push("tag");
    [5.2872]
    [5.2911]
    temp_path.push("tmp");
  • edit in pijul/src/commands/tag.rs at line 114
    [5.3230]
    [5.3230]
    tag_path.set_extension("tag");
  • replacement in pijul/src/commands/tag.rs at line 128
    [3.689][5.113:222](),[5.113][5.113:222]()
    let mut tag_path = repo.path.join(libpijul::DOT_DIR);
    tag_path.push("tags");
    [3.689]
    [5.3591]
    let mut tag_path = repo.changes_dir.clone();
  • edit in pijul/src/commands/tag.rs at line 131
    [5.312]
    [5.3678]
    tag_path.set_extension("tag");
  • replacement in pijul/src/commands/tag.rs at line 147
    [5.4392][2.0:70]()
    let f = libpijul::tag::OpenTagFile::open(&tag_path)?;
    [5.4198]
    [5.4457]
    let mut f = libpijul::tag::OpenTagFile::open(&tag_path)?;
    f.check(&h)?;
  • replacement in pijul/src/commands/tag.rs at line 155
    [5.5721][5.5721:5830]()
    let mut tag_path = repo.path.join(libpijul::DOT_DIR);
    tag_path.push("tags");
    [5.5721]
    [5.5830]
    let mut tag_path = repo.changes_dir.clone();
  • edit in pijul/src/commands/tag.rs at line 158
    [5.6006]
    [5.6006]
    tag_path.set_extension("tag");
  • replacement in pijul/src/commands/tag.rs at line 164
    [5.6132][4.0:71]()
    let tag = libpijul::tag::txn::TagTxn::new(&tag_path)?;
    [5.6132]
    [5.6211]
    let tag = libpijul::tag::txn::TagTxn::new(&tag_path, &h)?;
  • replacement in pijul/src/commands/tag.rs at line 200
    [5.708][5.708:817]()
    let mut tag_path = repo.path.join(libpijul::DOT_DIR);
    tag_path.push("tags");
    [5.708]
    [5.817]
    let mut tag_path = repo.changes_dir.clone();
  • edit in pijul/src/commands/tag.rs at line 206
    [5.1110]
    [5.1110]
    tag_path.set_extension("tag");
  • edit in libpijul/src/tag.rs at line 60
    [5.7538]
    [5.7538]
    #[error("Wrong hash, expected {}, got {}", expected.to_base32(), got.to_base32())]
    WrongHash { expected: Hash, got: Hash },
  • edit in libpijul/src/tag.rs at line 97
    [5.1983]
    [5.8014]
    pub fn check(&mut self, expected: &Hash) -> Result<(), TagError> {
    let mut hasher = Hasher::default();
    self.file.seek(SeekFrom::Start(0))?;
    let mut buf = Vec::new();
    // Reading the FileHeader
    buf.resize(self.header.header as usize, 0);
    self.file.read_exact(&mut buf)?;
    hasher.update(&buf);
    // Reading the Header
    buf.resize((self.header.channel - self.header.header) as usize, 0);
    self.file.read_exact(&mut buf)?;
    hasher.update(&buf);
    // Reading the Header
    buf.resize((self.header.unhashed - self.header.channel) as usize, 0);
    self.file.read_exact(&mut buf)?;
    hasher.update(&buf);
    let got = hasher.finish();
    if &got != expected {
    Err(TagError::WrongHash {
    expected: *expected,
    got,
    })
    } else {
    Ok(())
    }
    }