| 1822 | } |
| 1823 | |
| 1824 | struct ref_iterator *refs_ref_iterator_begin( |
| 1825 | struct ref_store *refs, |
| 1826 | const char *prefix, |
| 1827 | const char **exclude_patterns, |
| 1828 | int trim, |
| 1829 | enum refs_for_each_flag flags) |
| 1830 | { |
| 1831 | struct ref_iterator *iter; |
| 1832 | struct strvec normalized_exclude_patterns = STRVEC_INIT; |
| 1833 | |
| 1834 | if (exclude_patterns) { |
| 1835 | for (size_t i = 0; exclude_patterns[i]; i++) { |
| 1836 | const char *pattern = exclude_patterns[i]; |
| 1837 | size_t len = strlen(pattern); |
| 1838 | if (!len) |
| 1839 | continue; |
| 1840 | |
| 1841 | if (pattern[len - 1] == '/') |
| 1842 | strvec_push(&normalized_exclude_patterns, pattern); |
| 1843 | else |
| 1844 | strvec_pushf(&normalized_exclude_patterns, "%s/", |
| 1845 | pattern); |
| 1846 | } |
| 1847 | |
| 1848 | exclude_patterns = normalized_exclude_patterns.v; |
| 1849 | } |
| 1850 | |
| 1851 | if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN)) { |
| 1852 | static int ref_paranoia = -1; |
| 1853 | |
| 1854 | if (ref_paranoia < 0) |
| 1855 | ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 1); |
| 1856 | if (ref_paranoia) { |
| 1857 | flags |= REFS_FOR_EACH_INCLUDE_BROKEN; |
| 1858 | flags |= REFS_FOR_EACH_OMIT_DANGLING_SYMREFS; |
| 1859 | } |
| 1860 | } |
| 1861 | |
| 1862 | iter = refs->be->iterator_begin(refs, prefix, exclude_patterns, flags); |
| 1863 | /* |
| 1864 | * `iterator_begin()` already takes care of prefix, but we |
| 1865 | * might need to do some trimming: |
| 1866 | */ |
| 1867 | if (trim) |
| 1868 | iter = prefix_ref_iterator_begin(iter, "", trim); |
| 1869 | |
| 1870 | strvec_clear(&normalized_exclude_patterns); |
| 1871 | |
| 1872 | return iter; |
| 1873 | } |
| 1874 | |
| 1875 | int refs_for_each_ref_ext(struct ref_store *refs, |
| 1876 | refs_for_each_cb cb, void *cb_data, |
no test coverage detected