Skip to content

fix: use git index ctime on v9fs#159

Merged
genedna merged 2 commits into
libra-tools:mainfrom
Ivanbeethoven:main
Jul 6, 2026
Merged

fix: use git index ctime on v9fs#159
genedna merged 2 commits into
libra-tools:mainfrom
Ivanbeethoven:main

Conversation

@Ivanbeethoven

Copy link
Copy Markdown
Contributor

Summary

  • Fix Git index entry timestamp creation on filesystems where birth/creation time is unavailable, such as WSL 9p/drvfs paths.
  • Keep index metadata stable by using ctime on Unix and falling back safely instead of unwrapping Metadata::created().

Validation

  • Reproduced the old panic with pre-fix Libra 1b4665f0 on /mnt/d/code/rustpan where stat tracked.txt reports Birth: -.
  • Old libra add tracked.txt failed with creation time is not available for the filesystem at git-internal-0.8.1/src/internal/index.rs:154.
  • Synced Ivanbeethoven/git-internal@20d2810 with Ivanbeethoven/libra@d48c9721 using Libra's local ../git-internal patch.
  • Ran LIBRA_SKIP_WEB_BUILD=1 cargo check --locked --bin libra and LIBRA_SKIP_WEB_BUILD=1 cargo build --locked --bin libra.
  • Verified fixed libra add tracked.txt succeeds on /mnt/d/code/rustpan/libra-v9fs-fixed-worktree-test; libra status --short reports A tracked.txt.

@Ivanbeethoven Ivanbeethoven marked this pull request as ready for review July 6, 2026 04:49
@genedna genedna requested a review from Copilot July 6, 2026 05:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_mtime helpers and a Unix unix_metadata_time converter to derive stable SystemTime values 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 thread src/internal/index.rs
Comment on lines +68 to +72
#[cfg(unix)]
fn index_ctime(meta: &fs::Metadata) -> SystemTime {
unix_metadata_time(meta.ctime(), meta.ctime_nsec())
}

@genedna genedna merged commit 26cb0b7 into libra-tools:main Jul 6, 2026
3 of 4 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.

4 participants