Skip to content

fix(git): error on missing operations child mapping - #206

Closed
presempathy-awb wants to merge 1 commit into
zhangfengcdt:mainfrom
presempathy-awb:pr-clean/git-operations-missing-child-mapping
Closed

fix(git): error on missing operations child mapping#206
presempathy-awb wants to merge 1 commit into
zhangfengcdt:mainfrom
presempathy-awb:pr-clean/git-operations-missing-child-mapping

Conversation

@presempathy-awb

Copy link
Copy Markdown
Contributor

Git Operations Error On Missing Historical Child Mapping

Bug

GitOperations::diff, show, and revert reconstruct historical key/value
state directly from a commit's prolly_config_tree_config and
prolly_hash_mappings files. During internal-node traversal, a child hash that
was absent from the historical mapping file was skipped instead of reported.

Impact

A corrupt historical mapping file could make a whole child subtree disappear
from git-prolly diff or git-prolly show. The CLI could then report fake
deletions, and GitOperations::revert could apply an incorrect inverse change
based on incomplete historical state.

Fix

Historical traversal now carries the expected node hash through recursion and
validates every internal child edge. Child hash bytes must have the configured
digest length, every child hash must exist in the historical mapping file, and
cyclic child references are rejected.

Regression Proof

The branch adds show_reports_missing_historical_child_mapping in
src/git/operations.rs. The test creates a multi-level historical tree, commits
a deliberately corrupt mapping file with one child mapping removed, restores a
good mapping in a later HEAD commit, then asks GitOperations::show to inspect
the corrupt historical commit.

Against the unfixed code, show returned Ok(_) and reported fake removals for
the missing child subtree. The fixed branch returns an error mentioning the
missing child mapping.

Verification

Run on fix/git-operations-missing-child-mapping:

  • RUSTC="$HOME/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc" CARGO_TARGET_DIR=/tmp/prollytree-ops-missing-child-target /opt/homebrew/bin/cargo test --lib --features git show_reports_missing_historical_child_mapping -- --nocapture
  • RUSTC="$HOME/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc" CARGO_TARGET_DIR=/tmp/prollytree-ops-missing-child-target /opt/homebrew/bin/cargo test --lib --features git git::operations::tests -- --nocapture
  • /opt/homebrew/bin/cargo fmt --all -- --check
  • RUSTC="$HOME/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc" CARGO_TARGET_DIR=/tmp/prollytree-ops-missing-child-target /opt/homebrew/bin/cargo build --all
  • timeout 240 zsh -lc 'CARGO_TARGET_DIR=/tmp/prollytree-ops-missing-child-clippy-target /opt/homebrew/bin/cargo clippy --all -q; rc=$?; echo CLIPPY_STATUS:$rc; exit $rc'

@zhangfengcdt zhangfengcdt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed: implementation and tests pass; no public API surface change detected.

@zhangfengcdt

Copy link
Copy Markdown
Owner

Resolved and integrated via #245 after the full CI matrix 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.

2 participants