MCPcopy Index your code
hub / github.com/git/git / has_uncommitted_changes

Function has_uncommitted_changes

wt-status.c:2648–2677  ·  view source on GitHub ↗

* Returns 1 if there are uncommitted changes, 0 otherwise. */

Source from the content-addressed store, hash-verified

2646 * Returns 1 if there are uncommitted changes, 0 otherwise.
2647 */
2648int has_uncommitted_changes(struct repository *r,
2649 int ignore_submodules)
2650{
2651 struct rev_info rev_info;
2652 int result;
2653
2654 if (is_index_unborn(r->index))
2655 return 0;
2656
2657 repo_init_revisions(r, &rev_info, NULL);
2658 if (ignore_submodules)
2659 rev_info.diffopt.flags.ignore_submodules = 1;
2660 rev_info.diffopt.flags.quick = 1;
2661
2662 add_head_to_pending(&rev_info);
2663 if (!rev_info.pending.nr) {
2664 /*
2665 * We have no head (or it's corrupt); use the empty tree,
2666 * which will complain if the index is non-empty.
2667 */
2668 struct tree *tree = lookup_tree(r, r->hash_algo->empty_tree);
2669 add_pending_object(&rev_info, &tree->object, "");
2670 }
2671
2672 diff_setup_done(&rev_info.diffopt);
2673 run_diff_index(&rev_info, DIFF_INDEX_CACHED);
2674 result = diff_result_code(&rev_info);
2675 release_revisions(&rev_info);
2676 return result;
2677}
2678
2679/**
2680 * If the work tree has unstaged or uncommitted changes, dies with the

Callers 3

commit_staged_changesFunction · 0.85
require_clean_work_treeFunction · 0.85

Calls 9

is_index_unbornFunction · 0.85
repo_init_revisionsFunction · 0.85
add_head_to_pendingFunction · 0.85
lookup_treeFunction · 0.85
add_pending_objectFunction · 0.85
diff_setup_doneFunction · 0.85
run_diff_indexFunction · 0.85
diff_result_codeFunction · 0.85
release_revisionsFunction · 0.85

Tested by

no test coverage detected