Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/helper/test-cache-entry.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / helper / test-cache-entry.c` 35 lines ยท 993 bytes Raw Blame History 1 #define USE_THE_REPOSITORY_VARIABLE 2 #include "test-tool.h" 3 #include "read-cache-ll.h" 4 5 /* 6 * Exercise the cache-entry name-length guard without having to construct a 7 * multi-gigabyte pathname in memory. make_empty_cache_entry() 8 * dies on any length that would not survive being stored in the 32-bit 9 * "ce_namelen" field, and it does so before allocating, so an out-of-range 10 * length is cheap to test. 11 */ 12 int cmd__cache_entry(int argc, const char **argv) 13 { 14 size_t len; 15 char *end; 16 struct cache_entry *ce; 17 18 if (argc != 2) 19 die("usage: test-tool cache-entry "); 20 21 errno = 0; 22 len = strtoumax(argv[1], &end, 10); 23 if (errno || *end) 24 die("cannot parse namelen '%s'", argv[1]); 25 26 /* Dies here if 'len' is too large to be represented safely. */ 27 ce = make_empty_cache_entry(the_repository->index, len); 28 if (!ce) 29 die("failed to create cache entry"); 30 31 printf("ok: allocated cache entry for namelen %"PRIuMAX"\n", 32 (uintmax_t)len); 33 discard_cache_entry(ce); 34 return 0; 35 }