fix: use git index ctime on v9fs#159
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Git index timestamp handling to avoid panics on filesystems that don’t expose file creation (“birth”) time (notably WSL 9p/drvfs mounts). It aligns index entry timestamps more closely with Git’s intended semantics by using Unix ctime/mtime and providing stable fallbacks instead of unwrapping Metadata::created().
Changes:
- Introduce
index_ctime/index_mtimehelpers and a Unixunix_metadata_timeconverter to derive stableSystemTimevalues from platform metadata. - Replace
created().unwrap()/modified().unwrap()usage in index entry creation/refresh/modified-check code paths with the new helpers to prevent runtime panics. - Bump crate version to
0.8.2(and update lockfile accordingly).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/internal/index.rs |
Implements platform-aware ctime/mtime selection and removes unwrap-based timestamp access in index entry paths. |
Cargo.toml |
Bumps package version to 0.8.2. |
Cargo.lock |
Updates lockfile entry for the new git-internal version. |
Comment on lines
+68
to
+72
| #[cfg(unix)] | ||
| fn index_ctime(meta: &fs::Metadata) -> SystemTime { | ||
| unix_metadata_time(meta.ctime(), meta.ctime_nsec()) | ||
| } | ||
|
|
genedna
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Metadata::created().Validation
1b4665f0on/mnt/d/code/rustpanwherestat tracked.txtreportsBirth: -.libra add tracked.txtfailed withcreation time is not available for the filesystematgit-internal-0.8.1/src/internal/index.rs:154.Ivanbeethoven/git-internal@20d2810withIvanbeethoven/libra@d48c9721using Libra's local../git-internalpatch.LIBRA_SKIP_WEB_BUILD=1 cargo check --locked --bin libraandLIBRA_SKIP_WEB_BUILD=1 cargo build --locked --bin libra.libra add tracked.txtsucceeds on/mnt/d/code/rustpan/libra-v9fs-fixed-worktree-test;libra status --shortreportsA tracked.txt.