Commit 88f5d26
committed
restore: avoid sparse index expansion
Teach update_some() to handle sparse directory entries at the tree
level rather than expanding the entire sparse index. When iterating a
source tree during checkout/restore operations:
- If a directory matches a sparse directory entry with the same OID,
skip it entirely (no change needed).
- If the OID differs and we are in non-overlay mode (e.g., restore
--staged), update the sparse directory entry's OID in place. This
is semantically correct because non-overlay mode removes paths not
in the source tree anyway.
- In overlay mode (e.g., checkout <tree> -- .), fall through to
recursive descent so individual file entries are preserved
correctly.
Also switch from index_name_pos() to index_name_pos_sparse() for
individual file lookups to avoid triggering ensure_full_index() when
the file is already individually tracked in the index.
Update the test expectation in t1092 to assert that 'restore --staged'
no longer expands the sparse index.
Signed-off-by: Derrick Stolee <stolee@gmail.com>1 parent 7c56d03 commit 88f5d26
2 files changed
Lines changed: 63 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
144 | 193 | | |
145 | | - | |
| 194 | + | |
146 | 195 | | |
147 | 196 | | |
148 | 197 | | |
149 | 198 | | |
| 199 | + | |
150 | 200 | | |
151 | 201 | | |
152 | | - | |
| 202 | + | |
| 203 | + | |
153 | 204 | | |
154 | 205 | | |
155 | 206 | | |
| |||
165 | 216 | | |
166 | 217 | | |
167 | 218 | | |
168 | | - | |
| 219 | + | |
169 | 220 | | |
170 | 221 | | |
171 | 222 | | |
| |||
182 | 233 | | |
183 | 234 | | |
184 | 235 | | |
185 | | - | |
| 236 | + | |
| 237 | + | |
186 | 238 | | |
187 | 239 | | |
188 | | - | |
| 240 | + | |
189 | 241 | | |
190 | 242 | | |
191 | 243 | | |
| |||
580 | 632 | | |
581 | 633 | | |
582 | 634 | | |
583 | | - | |
| 635 | + | |
| 636 | + | |
584 | 637 | | |
585 | 638 | | |
586 | 639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2608 | 2608 | | |
2609 | 2609 | | |
2610 | 2610 | | |
2611 | | - | |
| 2611 | + | |
2612 | 2612 | | |
2613 | 2613 | | |
2614 | 2614 | | |
2615 | 2615 | | |
2616 | | - | |
| 2616 | + | |
2617 | 2617 | | |
2618 | 2618 | | |
2619 | | - | |
| 2619 | + | |
2620 | 2620 | | |
2621 | 2621 | | |
2622 | 2622 | | |
2623 | | - | |
| 2623 | + | |
2624 | 2624 | | |
2625 | 2625 | | |
2626 | 2626 | | |
0 commit comments