| 2502 | } |
| 2503 | |
| 2504 | int repo_index_has_changes(struct repository *repo, |
| 2505 | struct tree *tree, |
| 2506 | struct strbuf *sb) |
| 2507 | { |
| 2508 | struct index_state *istate = repo->index; |
| 2509 | struct object_id cmp; |
| 2510 | int i; |
| 2511 | |
| 2512 | if (tree) |
| 2513 | cmp = tree->object.oid; |
| 2514 | if (tree || !repo_get_oid_tree(repo, "HEAD", &cmp)) { |
| 2515 | struct diff_options opt; |
| 2516 | |
| 2517 | repo_diff_setup(repo, &opt); |
| 2518 | opt.flags.exit_with_status = 1; |
| 2519 | if (!sb) |
| 2520 | opt.flags.quick = 1; |
| 2521 | diff_setup_done(&opt); |
| 2522 | do_diff_cache(&cmp, &opt); |
| 2523 | diffcore_std(&opt); |
| 2524 | for (i = 0; sb && i < diff_queued_diff.nr; i++) { |
| 2525 | if (i) |
| 2526 | strbuf_addch(sb, ' '); |
| 2527 | strbuf_addstr(sb, diff_queued_diff.queue[i]->two->path); |
| 2528 | } |
| 2529 | diff_flush(&opt); |
| 2530 | return opt.flags.has_changes != 0; |
| 2531 | } else { |
| 2532 | /* TODO: audit for interaction with sparse-index. */ |
| 2533 | ensure_full_index(istate); |
| 2534 | for (i = 0; sb && i < istate->cache_nr; i++) { |
| 2535 | if (i) |
| 2536 | strbuf_addch(sb, ' '); |
| 2537 | strbuf_addstr(sb, istate->cache[i]->name); |
| 2538 | } |
| 2539 | return !!istate->cache_nr; |
| 2540 | } |
| 2541 | } |
| 2542 | |
| 2543 | static int write_index_ext_header(struct hashfile *f, |
| 2544 | struct git_hash_ctx *eoie_f, |
no test coverage detected