Skip to content

fix(gix-date): reject ambiguous bare numeric dates - #3002

Merged
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
fix-8bit-date
Sep 16, 2026
Merged

Sebastian Thiel (Byron) merged 1 commit into
mainfrom
fix-8bit-date

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented Sep 16, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-6.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Fixes #3001.

gix_date::parse("20080214", None) now returns an error. Bare numeric timestamps must be at least 100000000, matching Git's threshold; explicit forms such as @0, @-1000, and @20080214 remain supported. The API documentation and existing example tests reflect this behavior.

The regression extends the existing Git baseline with six rejected bare numbers and three accepted explicit timestamps. Fixed-date samples now use GIT_AUTHOR_DATE with git var GIT_AUTHOR_IDENT, avoiding the expiry parser's approximate-date fallback. The regenerated archive preserves all 128 existing samples. Git reference: date.c::match_digit() and the threshold cases in t/t0006-date.sh; generated with Git 2.50.1 (Apple Git-155).

Validation:

  • Confirmed the new baseline failed on 20080214 before the fix.
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix-date -p gix-revision --features serde --quiet — 174 tests and the doctest pass.
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo +nightly test -p gix-date --all-features --doc --quiet — passes.
  • cargo clippy -p gix-date --all-targets --all-features -- -D warnings -A unknown-lints --no-deps — passes.
  • cargo fmt --all -- --check and fixture shell syntax validation — pass.
  • codex review --commit 5ea084aa50342a7bfe2fc1669744d35f026a45df — no findings.

<!-- agent -->
`parse("20080214", None)` silently returned epoch seconds in 1970 because
any signed integer was accepted before the flexible date parser. Apply
Git's `100000000` floor to bare timestamps so compact-date lookalikes,
zero, and negative numbers do not silently become epoch seconds. Explicit
`@` timestamps and raw commit-header dates retain their existing behavior.
Update the documented examples and their existing acceptance tests.

Extend the existing Git baseline with six rejected bare numbers and three
explicit raw timestamps. Generate fixed-date samples through
`GIT_AUTHOR_DATE` and `git var GIT_AUTHOR_IDENT`: the previous expiry-date
parser could fall back to approximate dates and conceal these errors.
The regenerated archive preserves all 128 existing baseline samples.
The regression failed on `20080214` before the parser change.

Git reference: `date.c::match_digit()` reserves numbers below `100000000`
for date components; `t/t0006-date.sh` covers the threshold and explicit
`@0 +0000`. Baselines were generated with Git 2.50.1 (Apple Git-155).

Assisted-by: GPT 6.0
Co-authored-by: GPT 6.0 <codex@openai.com>
@Byron
Sebastian Thiel (Byron) marked this pull request as ready for review September 16, 2026 09:47
@Byron
Sebastian Thiel (Byron) merged commit 2abc090 into main Sep 16, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gix-date: an 8-digit date like 20080214 is read as a Unix timestamp

1 participant