MCPcopy Index your code
hub / github.com/go-git/go-git / TestTreeFindEntryDuplicates

Function TestTreeFindEntryDuplicates

plumbing/object/tree_test.go:1873–1972  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1871}
1872
1873func TestTreeFindEntryDuplicates(t *testing.T) {
1874 t.Parallel()
1875
1876 hashA := bytes.Repeat([]byte{0xAA}, 20)
1877 hashB := bytes.Repeat([]byte{0xBB}, 20)
1878 hashC := bytes.Repeat([]byte{0xCC}, 20)
1879
1880 cases := []struct {
1881 name string
1882 body []byte
1883 lookup string
1884 wantHash []byte
1885 wantMode filemode.FileMode
1886 wantCount int
1887 }{
1888 {
1889 name: "two regular files with same name",
1890 body: encodeRawTreeEntries(
1891 rawTreeEntry{"100644", "foo", hashA},
1892 rawTreeEntry{"100644", "foo", hashB},
1893 ),
1894 lookup: "foo",
1895 wantHash: hashA,
1896 wantMode: filemode.Regular,
1897 wantCount: 2,
1898 },
1899 {
1900 name: "triplicate regular file",
1901 body: encodeRawTreeEntries(
1902 rawTreeEntry{"100644", "foo", hashA},
1903 rawTreeEntry{"100644", "foo", hashB},
1904 rawTreeEntry{"100644", "foo", hashC},
1905 ),
1906 lookup: "foo",
1907 wantHash: hashA,
1908 wantMode: filemode.Regular,
1909 wantCount: 3,
1910 },
1911 {
1912 name: "file shadows later directory of same name",
1913 body: encodeRawTreeEntries(
1914 rawTreeEntry{"100644", "foo", hashA},
1915 rawTreeEntry{"40000", "foo", hashB},
1916 ),
1917 lookup: "foo",
1918 wantHash: hashA,
1919 wantMode: filemode.Regular,
1920 wantCount: 2,
1921 },
1922 {
1923 name: "directory shadows later file of same name",
1924 body: encodeRawTreeEntries(
1925 rawTreeEntry{"40000", "foo", hashA},
1926 rawTreeEntry{"100644", "foo", hashB},
1927 ),
1928 lookup: "foo",
1929 wantHash: hashA,
1930 wantMode: filemode.Dir,

Callers

nothing calls this directly

Calls 9

SetTypeMethod · 0.95
WriterMethod · 0.95
DecodeMethod · 0.95
FindEntryMethod · 0.95
encodeRawTreeEntriesFunction · 0.85
CompareMethod · 0.80
CloseMethod · 0.65
WriteMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…