* Should empty commits be allowed? Return status: * <0: Error in is_index_unchanged(r) or is_original_commit_empty(commit) * 0: Halt on empty commit * 1: Allow empty commit * 2: Drop empty commit */
| 1785 | * 2: Drop empty commit |
| 1786 | */ |
| 1787 | static int allow_empty(struct repository *r, |
| 1788 | struct replay_opts *opts, |
| 1789 | struct commit *commit) |
| 1790 | { |
| 1791 | int index_unchanged, originally_empty; |
| 1792 | |
| 1793 | /* |
| 1794 | * For a commit that is initially empty, allow_empty determines if it |
| 1795 | * should be kept or not |
| 1796 | * |
| 1797 | * For a commit that becomes empty, keep_redundant_commits and |
| 1798 | * drop_redundant_commits determine whether the commit should be kept or |
| 1799 | * dropped. If neither is specified, halt. |
| 1800 | */ |
| 1801 | index_unchanged = is_index_unchanged(r); |
| 1802 | if (index_unchanged < 0) |
| 1803 | return index_unchanged; |
| 1804 | if (!index_unchanged) |
| 1805 | return 0; /* we do not have to say --allow-empty */ |
| 1806 | |
| 1807 | originally_empty = is_original_commit_empty(commit); |
| 1808 | if (originally_empty < 0) |
| 1809 | return originally_empty; |
| 1810 | if (originally_empty) |
| 1811 | return opts->allow_empty; |
| 1812 | else if (opts->keep_redundant_commits) |
| 1813 | return 1; |
| 1814 | else if (opts->drop_redundant_commits) |
| 1815 | return 2; |
| 1816 | else |
| 1817 | return 0; |
| 1818 | } |
| 1819 | |
| 1820 | static struct { |
| 1821 | char c; |
no test coverage detected