MCPcopy Create free account
hub / github.com/git/git / repo_index_has_changes

Function repo_index_has_changes

read-cache.c:2504–2541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2502}
2503
2504int 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
2543static int write_index_ext_header(struct hashfile *f,
2544 struct git_hash_ctx *eoie_f,

Callers 6

uncleanFunction · 0.85
die_user_resolveFunction · 0.85
am_runFunction · 0.85
am_resolveFunction · 0.85
cmd_mergeFunction · 0.85
cmd_history_fixupFunction · 0.85

Calls 9

repo_get_oid_treeFunction · 0.85
repo_diff_setupFunction · 0.85
diff_setup_doneFunction · 0.85
do_diff_cacheFunction · 0.85
diffcore_stdFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_addstrFunction · 0.85
diff_flushFunction · 0.85
ensure_full_indexFunction · 0.85

Tested by

no test coverage detected