Commit 1cfed6b
authored
Fix the staging issue with git-prolly (#51)
* Fix the staging issue with git-prolly
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
* fix save and load of the storage
* fix preserving prolly tree root issue
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.
* fixed the git-prolly issue where prolly list was showing "No keys found" 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 JSON1 parent a42a978 commit 1cfed6b
6 files changed
Lines changed: 564 additions & 76 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
401 | 406 | | |
402 | 407 | | |
403 | 408 | | |
404 | 409 | | |
405 | 410 | | |
406 | 411 | | |
407 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
408 | 418 | | |
409 | 419 | | |
410 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
36 | 55 | | |
37 | 56 | | |
38 | 57 | | |
39 | 58 | | |
40 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
41 | 63 | | |
42 | 64 | | |
43 | | - | |
| 65 | + | |
44 | 66 | | |
45 | 67 | | |
46 | 68 | | |
47 | 69 | | |
48 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
49 | 77 | | |
50 | 78 | | |
51 | 79 | | |
52 | 80 | | |
53 | 81 | | |
| 82 | + | |
54 | 83 | | |
55 | 84 | | |
56 | 85 | | |
57 | 86 | | |
58 | | - | |
| 87 | + | |
59 | 88 | | |
60 | 89 | | |
61 | 90 | | |
62 | 91 | | |
63 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
64 | 99 | | |
65 | 100 | | |
66 | 101 | | |
| |||
118 | 153 | | |
119 | 154 | | |
120 | 155 | | |
121 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
122 | 164 | | |
123 | 165 | | |
124 | 166 | | |
| |||
139 | 181 | | |
140 | 182 | | |
141 | 183 | | |
142 | | - | |
143 | | - | |
| 184 | + | |
144 | 185 | | |
145 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
146 | 191 | | |
147 | 192 | | |
148 | 193 | | |
149 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
150 | 268 | | |
151 | 269 | | |
152 | 270 | | |
| |||
186 | 304 | | |
187 | 305 | | |
188 | 306 | | |
189 | | - | |
190 | | - | |
| 307 | + | |
| 308 | + | |
191 | 309 | | |
192 | 310 | | |
193 | 311 | | |
| |||
210 | 328 | | |
211 | 329 | | |
212 | 330 | | |
213 | | - | |
214 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
215 | 335 | | |
216 | 336 | | |
217 | 337 | | |
| |||
0 commit comments