| 3364 | } |
| 3365 | |
| 3366 | static void possibly_cache_new_pair(struct rename_info *renames, |
| 3367 | struct diff_filepair *p, |
| 3368 | unsigned side, |
| 3369 | char *new_path) |
| 3370 | { |
| 3371 | int dir_renamed_side = 0; |
| 3372 | |
| 3373 | if (new_path) { |
| 3374 | /* |
| 3375 | * Directory renames happen on the other side of history from |
| 3376 | * the side that adds new files to the old directory. |
| 3377 | */ |
| 3378 | dir_renamed_side = 3 - side; |
| 3379 | } else { |
| 3380 | int val = strintmap_get(&renames->relevant_sources[side], |
| 3381 | p->one->path); |
| 3382 | if (val == RELEVANT_NO_MORE) { |
| 3383 | assert(p->status == 'D'); |
| 3384 | strset_add(&renames->cached_irrelevant[side], |
| 3385 | p->one->path); |
| 3386 | } |
| 3387 | if (val <= 0) |
| 3388 | return; |
| 3389 | } |
| 3390 | |
| 3391 | if (p->status == 'D') { |
| 3392 | /* |
| 3393 | * If we already had this delete, we'll just set it's value |
| 3394 | * to NULL again, so no harm. |
| 3395 | */ |
| 3396 | strmap_put(&renames->cached_pairs[side], p->one->path, NULL); |
| 3397 | } else if (p->status == 'R') { |
| 3398 | if (!new_path) |
| 3399 | new_path = p->two->path; |
| 3400 | else |
| 3401 | cache_new_pair(renames, dir_renamed_side, |
| 3402 | p->two->path, new_path, 0); |
| 3403 | cache_new_pair(renames, side, p->one->path, new_path, 1); |
| 3404 | } else if (p->status == 'A' && new_path) { |
| 3405 | cache_new_pair(renames, dir_renamed_side, |
| 3406 | p->two->path, new_path, 0); |
| 3407 | } |
| 3408 | } |
| 3409 | |
| 3410 | static int compare_pairs(const void *a_, const void *b_) |
| 3411 | { |
no test coverage detected