Skip to content

Commit f887d4a

Browse files
ChanTsuneVorpalBlade
authored andcommitted
fix: Honor nochange/optional keywords
nochange/optional keywords were parsed but stored as false, so Entry::no_change() and Entry::optional() always returned false. Set both flags to true when the keyword is present. Add a unit test covering nochange/optional parsing.
1 parent e5a62f9 commit f887d4a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

crates/mtree2/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ impl Params {
509509
Keyword::Md5(md5) => self.md5 = Some(md5),
510510
Keyword::Mode(mode) => self.mode = Some(mode),
511511
Keyword::NLink(nlink) => self.nlink = Some(nlink),
512-
Keyword::NoChange => self.no_change = false,
513-
Keyword::Optional => self.optional = false,
512+
Keyword::NoChange => self.no_change = true,
513+
Keyword::Optional => self.optional = true,
514514
Keyword::ResidentDeviceRef(device) => {
515515
self.resident_device = Some(Box::new(device.to_device()));
516516
}
@@ -758,4 +758,13 @@ size=581 \";
758758
};
759759
assert_eq!(entry, should);
760760
}
761+
762+
#[test]
763+
fn test_nochange_optional_flags() {
764+
let data = "foo nochange optional\n";
765+
let mut mtree = MTree::from_reader_with_empty_cwd(Cursor::new(data.as_bytes()));
766+
let entry = mtree.next().unwrap().unwrap();
767+
assert!(entry.no_change());
768+
assert!(entry.optional());
769+
}
761770
}

0 commit comments

Comments
 (0)