History

Merge branch 'fix-gix-rev'

Sebastian Thiel committed 3 years ago

Commit d3fb5372 parents c197cbf 045dd9d3 files · +10 −3Browse files

Unified · Split

3 files
  1. gix-date/src/time/write.rs +2 −2
  2. gix-revision/src/spec/parse/function.rs +1 −1
  3. gix-revision/tests/spec/parse/anchor/at_symbol.rs +7 −0
gix-date/src/time/write.rs+2−2
@@ -23,8 +23,8 @@ impl Time { · 22 unmodified lines
2323
2424 const ZERO: &[u8; 1] = b"0";
2525
26− const SECONDS_PER_HOUR: i32 = 60 * 60;
27− let offset = self.offset.abs();
26+ const SECONDS_PER_HOUR: u32 = 60 * 60;
27+ let offset = self.offset.unsigned_abs();
2828 let hours = offset / SECONDS_PER_HOUR;
2929 assert!(hours < 25, "offset is more than a day: {hours}");
3030 let minutes = (offset - (hours * SECONDS_PER_HOUR)) / 60;
gix-revision/src/spec/parse/function.rs+1−1
@@ -422,7 +422,7 @@ where · 421 unmodified lines
422422 if n < 0 {
423423 if name.is_empty() {
424424 delegate
425− .nth_checked_out_branch(n.abs().try_into().expect("non-negative isize fits usize"))
425+ .nth_checked_out_branch(n.unsigned_abs())
426426 .ok_or(Error::Delegate)?;
427427 } else {
428428 return Err(Error::RefnameNeedsPositiveReflogEntries { nav: nav.into() });
gix-revision/tests/spec/parse/anchor/at_symbol.rs+7−0
@@ -10,6 +10,13 @@ fn braces_must_be_closed() { · 9 unmodified lines
1010 }
1111 }
1212
13+#[test]
14+#[cfg_attr(target_pointer_width = "32", ignore = "Only works this way on 64 bit systems")]
15+fn fuzzed() {
16+ let rec = parse("@{-9223372036854775808}");
17+ assert_eq!(rec.nth_checked_out_branch, [Some(9223372036854775808), None]);
18+}
19+
1320 #[test]
1421 fn reflog_by_entry_for_current_branch() {
1522 for (spec, expected_entry) in [("@{0}", 0), ("@{42}", 42), ("@{00100}", 100)] {