Git fork

Merge branch 'tb/refs-exclude-fixes'

The refname exclusion logic in the packed-ref backend has been
broken for some time, which confused upload-pack to advertise
different set of refs. This has been corrected.

* tb/refs-exclude-fixes:
refs.c: stop matching non-directory prefixes in exclude patterns
refs.c: remove empty '--exclude' patterns

+44 -2
+20
refs.c
··· 1699 1699 enum do_for_each_ref_flags flags) 1700 1700 { 1701 1701 struct ref_iterator *iter; 1702 + struct strvec normalized_exclude_patterns = STRVEC_INIT; 1703 + 1704 + if (exclude_patterns) { 1705 + for (size_t i = 0; exclude_patterns[i]; i++) { 1706 + const char *pattern = exclude_patterns[i]; 1707 + size_t len = strlen(pattern); 1708 + if (!len) 1709 + continue; 1710 + 1711 + if (pattern[len - 1] == '/') 1712 + strvec_push(&normalized_exclude_patterns, pattern); 1713 + else 1714 + strvec_pushf(&normalized_exclude_patterns, "%s/", 1715 + pattern); 1716 + } 1717 + 1718 + exclude_patterns = normalized_exclude_patterns.v; 1719 + } 1702 1720 1703 1721 if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) { 1704 1722 static int ref_paranoia = -1; ··· 1718 1736 */ 1719 1737 if (trim) 1720 1738 iter = prefix_ref_iterator_begin(iter, "", trim); 1739 + 1740 + strvec_clear(&normalized_exclude_patterns); 1721 1741 1722 1742 return iter; 1723 1743 }
+24 -2
t/t1419-exclude-refs.sh
··· 46 46 echo "create refs/heads/$name/$i $base" || return 1 47 47 done || return 1 48 48 done >in && 49 + for i in 5 6 7 50 + do 51 + echo "create refs/heads/bar/4/$i $base" || return 1 52 + done >>in && 49 53 echo "delete refs/heads/main" >>in && 50 54 51 55 git update-ref --stdin <in && ··· 99 103 esac 100 104 ' 101 105 102 - test_expect_success 'overlapping excluded regions' ' 106 + test_expect_success 'non-directory excluded regions' ' 103 107 for_each_ref__exclude refs/heads refs/heads/ba refs/heads/baz >actual 2>perf && 104 - for_each_ref refs/heads/foo refs/heads/quux >expect && 108 + for_each_ref refs/heads/bar refs/heads/foo refs/heads/quux >expect && 109 + 110 + test_cmp expect actual && 111 + assert_jumps 1 perf 112 + ' 113 + 114 + test_expect_success 'overlapping excluded regions' ' 115 + for_each_ref__exclude refs/heads refs/heads/bar refs/heads/bar/4 >actual 2>perf && 116 + for_each_ref refs/heads/baz refs/heads/foo refs/heads/quux >expect && 105 117 106 118 test_cmp expect actual && 107 119 assert_jumps 1 perf ··· 149 161 150 162 test_expect_success 'meta-characters are discarded' ' 151 163 for_each_ref__exclude refs/heads "refs/heads/ba*" >actual 2>perf && 164 + for_each_ref >expect && 165 + 166 + test_cmp expect actual && 167 + assert_no_jumps perf 168 + ' 169 + 170 + test_expect_success 'empty string exclude pattern is ignored' ' 171 + git update-ref refs/heads/loose $(git rev-parse refs/heads/foo/1) && 172 + 173 + for_each_ref__exclude refs/heads "" >actual 2>perf && 152 174 for_each_ref >expect && 153 175 154 176 test_cmp expect actual &&