| 226 | } |
| 227 | |
| 228 | struct odb_source *odb_set_temporary_primary_source(struct object_database *odb, |
| 229 | const char *dir, int will_destroy) |
| 230 | { |
| 231 | struct odb_source *source; |
| 232 | |
| 233 | /* |
| 234 | * Make sure alternates are initialized, or else our entry may be |
| 235 | * overwritten when they are. |
| 236 | */ |
| 237 | odb_prepare_alternates(odb); |
| 238 | |
| 239 | /* |
| 240 | * Make a new primary odb and link the old primary ODB in as an |
| 241 | * alternate |
| 242 | */ |
| 243 | source = odb_source_new(odb, dir, false); |
| 244 | |
| 245 | /* |
| 246 | * Disable ref updates while a temporary odb is active, since |
| 247 | * the objects in the database may roll back. |
| 248 | */ |
| 249 | odb->repo->disable_ref_updates = true; |
| 250 | source->will_destroy = will_destroy; |
| 251 | source->next = odb->sources; |
| 252 | odb->sources = source; |
| 253 | return source->next; |
| 254 | } |
| 255 | |
| 256 | void odb_restore_primary_source(struct object_database *odb, |
| 257 | struct odb_source *restore_source, |
no test coverage detected