Validate the entire selection before allocating its maps or querying any * object. Index-vector multiplication was checked at the public boundary. */
| 1867 | /* Validate the entire selection before allocating its maps or querying any |
| 1868 | * object. Index-vector multiplication was checked at the public boundary. */ |
| 1869 | static bool gf_batch_selection(gf_batch_work_t *work, cbm_git_facts_error_t *error) { |
| 1870 | size_t count = work->request->count; |
| 1871 | for (size_t i = 0; i < count; i++) { |
| 1872 | if (!gf_gate(work->facts, error)) |
| 1873 | return false; |
| 1874 | size_t index = work->request->indices[i]; |
| 1875 | if (index >= work->inventory.count) |
| 1876 | return gf_error(error, CBM_GIT_FACTS_INVALID, |
| 1877 | "Git batch inventory index is out of range"); |
| 1878 | const cbm_git_tree_entry_t *entry = &work->inventory.entries[index]; |
| 1879 | if (entry->object_type != CBM_GIT_TREE_BLOB || |
| 1880 | (entry->mode != 0100644 && entry->mode != 0100755)) |
| 1881 | return gf_error(error, CBM_GIT_FACTS_UNSUPPORTED, "Git batch requires regular blobs"); |
| 1882 | } |
| 1883 | work->picks = gf_batch_array(work->facts, count, sizeof(*work->picks), error); |
| 1884 | if (!work->picks) |
| 1885 | return false; |
| 1886 | for (size_t i = 0; i < count; i++) { |
| 1887 | if (!gf_gate(work->facts, error)) |
| 1888 | return false; |
| 1889 | size_t index = work->request->indices[i]; |
| 1890 | work->picks[i] = (gf_batch_pick_t){ |
| 1891 | .entry = &work->inventory.entries[index], .inventory_index = index, .position = i}; |
| 1892 | } |
| 1893 | return gf_batch_sort(work, error); |
| 1894 | } |
| 1895 | |
| 1896 | static bool gf_batch_unique(gf_batch_work_t *work, cbm_git_facts_error_t *error) { |
| 1897 | size_t count = work->request->count, width = work->facts->identity.oid_hex_length; |
no test coverage detected