| 1 | package fixtures |
| 2 | |
| 3 | // PackfileEntry maps an object hash (hex-encoded) to its byte offset in the packfile. |
| 4 | type PackfileEntry = map[string]int64 |
| 5 | |
| 6 | type packfileData struct { |
| 7 | hashes []string |
| 8 | offsets []int64 |
| 9 | } |
| 10 | |
| 11 | // Entries returns the expected object entries for this fixture's packfile. |
| 12 | // Each entry maps an object hash (hex-encoded) to its byte offset in the packfile. |
| 13 | // Returns nil if no entries are registered for this fixture's packfile. |
| 14 | func (f *Fixture) Entries() PackfileEntry { |
| 15 | d, ok := packfileEntries[f.PackfileHash] |
| 16 | if !ok { |
| 17 | return nil |
| 18 | } |
| 19 | |
| 20 | m := make(PackfileEntry, len(d.hashes)) |
| 21 | for i, h := range d.hashes { |
| 22 | m[h] = d.offsets[i] |
| 23 | } |
| 24 | |
| 25 | return m |
| 26 | } |
| 27 | |
| 28 | // ScannerEntry represents a single object as read from the packfile stream. |
| 29 | // Fields use plain types so go-git-fixtures does not depend on go-git. |
| 30 | // |
| 31 | // Object type constants match plumbing.ObjectType: |
| 32 | // 1=commit, 2=tree, 3=blob, 4=tag, 6=ofs-delta, 7=ref-delta. |
| 33 | type ScannerEntry struct { |
| 34 | Type int |
| 35 | Offset int64 |
| 36 | Size int64 |
| 37 | Hash string // hex-encoded; empty for delta objects |
| 38 | Reference string // hex-encoded; base object hash for ref-delta |
| 39 | OffsetReference int64 // base object offset for ofs-delta |
| 40 | CRC32 uint32 |
| 41 | } |
| 42 | |
| 43 | // ScannerEntries returns the expected scanner output for this fixture's packfile, |
| 44 | // ordered by pack stream offset. Returns nil if not registered. |
| 45 | func (f *Fixture) ScannerEntries() []ScannerEntry { |
| 46 | entries, ok := scannerEntries[f.PackfileHash] |
| 47 | if !ok { |
| 48 | return nil |
| 49 | } |
| 50 | |
| 51 | out := make([]ScannerEntry, len(entries)) |
| 52 | copy(out, entries) |
| 53 | |
| 54 | return out |
| 55 | } |
| 56 | |
| 57 | // basicSHA1Hashes are the 31 object hashes in basic.git (SHA1 format), sorted lexicographically. |
| 58 | // Shared across ofs-delta and ref-delta packfiles which contain the same objects at different offsets. |
| 59 | // |
| 60 | //nolint:gochecknoglobals |
| 61 | var basicSHA1Hashes = [...]string{ |
| 62 | "1669dce138d9b841a518c64b10914d88f5e488ea", |
| 63 | "32858aad3c383ed1ff0a0f9bdf231d54a00c9e88", |
| 64 | "35e85108805c84807bc66a02d91535e1e24b38b9", |
| 65 | "49c6bb89b17060d7b4deacb7b338fcc6ea2352a9", |
| 66 | "4d081c50e250fa32ea8b1313cf8bb7c2ad7627fd", |
| 67 | "586af567d0bb5e771e49bdd9434f5e0fb76d25fa", |
| 68 | "5a877e6a906a2743ad6e45d99c1793642aaf8eda", |
| 69 | "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", |
| 70 | "7e59600739c96546163833214c36459e324bad0a", |
| 71 | "880cd14280f4b9b6ed3986d6671f907d7cc2a198", |
| 72 | "8dcef98b1d52143e1e2dbc458ffe38f925786bf2", |
| 73 | "918c48b83bd081e863dbe1b80f8998f058cd8294", |
| 74 | "9a48f23120e880dfbe41f7c9b7b708e9ee62a492", |
| 75 | "9dea2395f5403188298c1dabe8bdafe562c491e3", |
| 76 | "a39771a7651f97faf5c72e08224d857fc35133db", |
| 77 | "a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69", |
| 78 | "a8d315b2b1c615d43042c3a62402b8a54288cf5c", |
| 79 | "aa9b383c260e1d05fbbf6b30a02914555e20c725", |
| 80 | "af2d6a6954d532f8ffb47615169c8fdf9d383a1a", |
| 81 | "b029517f6300c2da0f4b651b8642506cd6aaf45d", |
| 82 | "b8e471f58bcbca63b07bda20e428190409c2db47", |
| 83 | "c192bd6a24ea1ab01d78686e417c8bdc7c3d197f", |
| 84 | "c2d30fa8ef288618f65f6eed6e168e0d514886f4", |
| 85 | "c8f1d8c61f9da76f4cb49fd86322b6e685dba956", |
| 86 | "cf4aa3b38974fb7d81f367c0830f7d78d65ab86b", |
| 87 | "d3ff53e0564a9f87d8e84b6e28e5060e517008aa", |
| 88 | "d5c0f4ab811897cadf03aec358ae60d21f91c50d", |
| 89 | "dbd3641b371024f44d0e469a9c8f5457b0660de1", |
| 90 | "e8d3ffab552895c19b9fcf7aa264d277cde33881", |
| 91 | "eba74343e2f15d62adedfd8c883ee0262b5c8021", |
| 92 | "fb72698cab7617ac416264415f13224dfd7a165e", |
| 93 | } |
| 94 | |
| 95 | // basicSHA256Hashes are the 36 object hashes in basic.git (SHA256 format), sorted lexicographically. |
| 96 | // |
| 97 | //nolint:gochecknoglobals |
| 98 | var basicSHA256Hashes = [...]string{ |
| 99 | "011218223f6e9e4a7f7ed704999158d6a3d080bedff536983c0d0e03d262c664", |
| 100 | "030d8320428f364839a75c1fe8d4cc2cdada2b683dcaffcc94d9770640302dd1", |
| 101 | "176d63c1aa704b4021d82cc75c6a8a7bbd96c7b30d774d7e629773581cfd4501", |
| 102 | "1e7242fb7dfbf84896c05ee1f2fde2d591103cc5f6e5b9c7f8562b51e9e1732b", |
| 103 | "1f307724f91af43be1570b77aeef69c5010e8136e50bef83c28de2918a08f494", |
| 104 | "23e6fd7f90c8b0d3dddd48d8a87a00662972b8a917d4d7fc2d0967921b65f3ed", |
| 105 | "2849f40d9cd298ce2a85d6dc603e84c99e6c6bcbf798740b57bc7deaaa913360", |
| 106 | "2a246d3eaea67b7c4ac36d96d1dc9dad2a4dc24486c4d67eb7cb73963f522481", |
| 107 | "2a7543a59f760f7ca41784bc898057799ae960323733cab1175c21960a750f72", |
| 108 | "2ad4c66a3680b32a04547b749c105edb5421ddffd4fac791fd24368b23c7ffc6", |
| 109 | "33a5013ed4af64b6e54076c986a4733c2c11ce8ab27ede79f21366e8722ac5ed", |
| 110 | "38ad2967b54c80797487d45a5db951406d72927580faeb224a678576f962bcef", |
| 111 | "40b7c05726c9da78c3d5a705c2a48a120261b36f521302ce06bad41916d000f7", |
| 112 | "4c61794e77ff8c7ab7f07404cdb1bc0e989b27530e37a6be6d2ef73639aaff6d", |
| 113 | "4c75fc7e8111ca9dc7f087c85f1a6f969f6e394034acd203d4f07562e668bb95", |
| 114 | "4fef4adac3be863b9b94613016bdd8e53f67f6d7577234e028bc9d24c5a6a27c", |
| 115 | "53a77fb45346d765b3d7054ab6ed3e7a227cb3b81ac2c60c83d0a8308a15264c", |
| 116 | "5dd3e66d32270068b4ed56cedc1b82b9b39e2dde6df9aa724092879a4cddad6b", |
| 117 | "65bb8b5ad068a89499ce27b1e0397fb4c027c013d7c407671bb8c70777f78e13", |
| 118 | "665e33431d9b88280d7c1837680fdb66664c4cb4b394c9057cdbd07f3b4acff8", |
| 119 | "6e8d71fbfd367c34968d31ef8886929a9862b02de4616bfc569583b3f5a76808", |
| 120 | "73660d98a4c6c8951f86bb8c4744a0b4837a6dd5f796c314064c1615781c400c", |
| 121 | "789c9f4220d167b66020b46bacddcad0ab5bb12f0f469576aa60bb59d98293dc", |
| 122 | "80d53c7b7196c44b0abd4d102772dedeb33069b617e5df2f0becc2563a37e1b0", |
| 123 | "8cc70e96f2ee81cdad77361933640703a42ee3a04fade68578e836714f535d76", |
| 124 | "9768a9bcb42f35dc598a517bd98a5cbba79052b980a8a015f3be5577ebd9f201", |
| 125 | "abb8b2cb27cba10e236e97e06e4a5a0acd6b50e89e8a6e974439a39cb4c3de00", |
| 126 | "ac16b517cae0a031a218f0edb988ae0df4ee267a531a8a35f17dba1787ea0422", |
| 127 | "b8bdc620cb4859cf6e48768fd67f526229f3a57aa417740024bf7e6af5fdb04c", |
| 128 | "c74a1ff56ec2c88a7e214436a560e30c0c4b699e92cb62449df487d4707bea3d", |
| 129 | "cbaa8eafbf007764f1ef3681261384359976a9edff18e906cbd6802fcdec6f75", |
| 130 | "e6ee53c7eb0e33417ee04110b84b304ff2da5c1b856f320b61ad9f2ef56c6e4e", |
| 131 | "e725c2efbb1bb3e5ff39d5b1cb6c38e33c7f294259974b367c157d811425776a", |
| 132 | "ee4e96e4a1684b5ad691c752be98c517bb4f71fbbef6c35e743c4accdbc1f231", |
| 133 | "ef36d9a576158df19554d50c9180d503ded2b86a85956d3da9bf1369449f34ab", |
| 134 | "fa60c322a88283ab1e9d872f4782eb4f4da7f98179e574ba85f58b992d918d6a", |
| 135 | } |
| 136 | |
| 137 | // packfileEntries maps packfile hashes to their object data. |
| 138 | // Hashes are shared across packfiles of the same repository and format; |
| 139 | // only the offsets differ between delta encodings. |
| 140 | // |
| 141 | //nolint:gochecknoglobals |
| 142 | var packfileEntries = map[string]packfileData{ |
| 143 | // basic.git ofs-delta (sha1) |
| 144 | "a3fed42da1e8189a077c0e6846c040dcf73fc9dd": { |
| 145 | hashes: basicSHA1Hashes[:], |
| 146 | offsets: []int64{ |
| 147 | 615, 1524, 1063, 78882, 84688, 84559, 84479, 186, |
| 148 | 84653, 78050, 84741, 286, 80998, 84032, 84430, 838, |
| 149 | 84375, 84760, 449, 1392, 1230, 1713, 84725, 80725, |
| 150 | 84608, 1685, 2351, 84115, 12, 84708, 84671, |
| 151 | }, |
| 152 | }, |
| 153 | // basic.git ref-delta (sha1) |
| 154 | "c544593473465e6315ad4182d04d366c4592b829": { |
| 155 | hashes: basicSHA1Hashes[:], |
| 156 | offsets: []int64{ |
| 157 | 633, 1542, 1243, 79129, 85262, 81265, 79049, 186, |
| 158 | 85244, 78117, 85448, 304, 81314, 84797, 78068, 856, |
| 159 | 84880, 85485, 467, 1410, 1081, 1731, 85335, 80972, |
| 160 | 84752, 1703, 2369, 85176, 12, 85300, 85141, |
| 161 | }, |
| 162 | }, |
| 163 | // basic.git (sha256) |
| 164 | "c88dfe1663bd216e278d5bb3c8decd0a4bb174a6204585dc44b7c7a05fceed55": { |
| 165 | hashes: basicSHA256Hashes[:], |
| 166 | offsets: []int64{ |
| 167 | 299, 1927, 85787, 85748, 85711, 85473, 1199, 82044, |
| 168 | 85540, 85483, 79369, 1464, 2674, 80201, 85417, 411, |
| 169 | 2267, 85805, 85826, 3501, 12, 82383, 2863, 85729, |
| 170 | 810, 2120, 79304, 79200, 608, 1732, 82317, 2835, |
| 171 | 1003, 85623, 85646, 85769, |
| 172 | }, |
| 173 | }, |
| 174 | } |