Commit 1cc8811
packed-backend: check whether the "packed-refs" is sorted
We will always try to sort the "packed-refs" increasingly by comparing
the refname. So, we should add checks to verify whether the "packed-refs"
is sorted.
It may seem that we could add a new "struct strbuf refname" into the
"struct fsck_packed_ref_entry" and during the parsing process, we could
store the refname into the entry and then we could compare later.
However, this is not a good design due to the following reasons:
1. Because we need to store the state across the whole checking
lifetime, we would consume a lot of memory if there are many entries
in the "packed-refs" file.
2. The most important is that we cannot reuse the existing compare
functions which cause repetition.
So, instead of storing the "struct strbuf", let's use the existing
structure "struct snaphost_record". And thus we could use the existing
function "cmp_packed_ref_records".
However, this function need an extra parameter for "struct snaphost".
Extract the common part into a new function "cmp_packed_ref_records" to
reuse this function to compare.
Then, create a new function "packed_fsck_ref_sorted" to use the new fsck
message "packedRefUnsorted(ERROR)" to report to the user.
Mentored-by: Patrick Steinhardt <[email protected]>
Mentored-by: Karthik Nayak <[email protected]>
Signed-off-by: shejialuo <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 8e182c5 commit 1cc8811
File tree
4 files changed
+111
-11
lines changed- Documentation
- refs
- t
4 files changed
+111
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
193 | 196 | | |
194 | 197 | | |
195 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | | - | |
| 304 | + | |
306 | 305 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | 306 | | |
313 | 307 | | |
314 | 308 | | |
| |||
323 | 317 | | |
324 | 318 | | |
325 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
326 | 331 | | |
327 | 332 | | |
328 | 333 | | |
| |||
1776 | 1781 | | |
1777 | 1782 | | |
1778 | 1783 | | |
| 1784 | + | |
| 1785 | + | |
1779 | 1786 | | |
1780 | 1787 | | |
1781 | | - | |
| 1788 | + | |
| 1789 | + | |
1782 | 1790 | | |
1783 | 1791 | | |
1784 | 1792 | | |
1785 | 1793 | | |
| 1794 | + | |
1786 | 1795 | | |
1787 | 1796 | | |
1788 | 1797 | | |
| |||
1981 | 1990 | | |
1982 | 1991 | | |
1983 | 1992 | | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
1984 | 2037 | | |
1985 | 2038 | | |
1986 | 2039 | | |
| |||
2010 | 2063 | | |
2011 | 2064 | | |
2012 | 2065 | | |
2013 | | - | |
| 2066 | + | |
2014 | 2067 | | |
2015 | 2068 | | |
2016 | 2069 | | |
| |||
2026 | 2079 | | |
2027 | 2080 | | |
2028 | 2081 | | |
| 2082 | + | |
2029 | 2083 | | |
2030 | 2084 | | |
2031 | 2085 | | |
2032 | 2086 | | |
2033 | 2087 | | |
2034 | 2088 | | |
2035 | | - | |
| 2089 | + | |
2036 | 2090 | | |
2037 | | - | |
| 2091 | + | |
2038 | 2092 | | |
| 2093 | + | |
| 2094 | + | |
2039 | 2095 | | |
2040 | 2096 | | |
2041 | 2097 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
765 | 765 | | |
766 | 766 | | |
767 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
768 | 808 | | |
0 commit comments