Skip to content

Conversation

zhangfengcdt
Copy link
Owner

No description provided.

Problem Identified

  The staging area (HashMap<Vec<u8>, Option<Vec<u8>>>) was being created fresh on each command invocation, causing staged changes to be
  lost between commands.

  Solution Implemented

  1. Added staging area persistence: Created save_staging_area() and load_staging_area() methods that serialize/deserialize the staging
  area to/from .git/PROLLY_STAGING file
  2. Fixed HEAD reference updates: Implemented proper update_head() method that writes branch references and HEAD file
  3. Updated all staging operations: Modified insert(), update(), delete(), and checkout() to persist staging area changes
  4. Fixed commit flow: Ensured staging area is cleared after successful commits
 The issue was that the original implementation was creating a Git tree with a null ObjectId
  placeholder, which resulted in the prolly_tree_root file being deleted during staging. Now it
  properly creates a real Git blob containing the serialized ProllyTree root and reconstructs the
  tree correctly when loading from HEAD.
…nd" after committing data

The problem had three root
  causes:

  1. Missing config save after commit

  - Issue: The commit() function wasn't calling save_config() after persisting the tree
  - Fix: Added self.tree.save_config() call in /Users/feng/github/prollytree/src/git/versioned_store.rs:216

  2. Hash mappings not loaded when opening store

  - Issue: GitNodeStorage::new() wasn't calling load_hash_mappings()
  - Fix: Added storage.load_hash_mappings() call in /Users/feng/github/prollytree/src/git/storage.rs:67

  3. ValueDigest deserialization incompatible with JSON

  - Issue: ValueDigest::deserialize() expected binary bytes but JSON config contained array format [188,78,66,...]
  - Fix: Updated deserialization in /Users/feng/github/prollytree/src/digest.rs:134 to handle Vec<u8> from JSON
to make sure prollytree metadata are kept
@zhangfengcdt zhangfengcdt merged commit 1cfed6b into main Jul 17, 2025
4 checks passed
@zhangfengcdt zhangfengcdt deleted the bugfix/fix-gitprolly-staging branch July 29, 2025 00:02
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.

1 participant