* Returns 1 if there are uncommitted changes, 0 otherwise. */
| 2646 | * Returns 1 if there are uncommitted changes, 0 otherwise. |
| 2647 | */ |
| 2648 | int 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 |
no test coverage detected