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-partial-clone.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-partial-clone.c` 48 lines ยท 1237 bytes Raw Blame History 1 #define USE_THE_REPOSITORY_VARIABLE 2 3 #include "test-tool.h" 4 #include "hex.h" 5 #include "repository.h" 6 #include "odb.h" 7 #include "setup.h" 8 9 /* 10 * Prints the size of the object corresponding to the given hash in a specific 11 * gitdir. This is similar to "git -C gitdir cat-file -s", except that this 12 * exercises the code that accesses the object of an arbitrary repository that 13 * is not the_repository. ("git -C gitdir" makes it so that the_repository is 14 * the one in gitdir.) 15 */ 16 static void object_info(const char *gitdir, const char *oid_hex) 17 { 18 struct repository r; 19 struct object_id oid; 20 size_t size; 21 struct object_info oi = {.sizep = &size}; 22 const char *p; 23 24 if (repo_init(&r, gitdir, NULL)) 25 die("could not init repo"); 26 if (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo)) 27 die("could not parse oid"); 28 if (odb_read_object_info_extended(r.objects, &oid, &oi, 0)) 29 die("could not obtain object info"); 30 printf("%d\n", (int) size); 31 32 repo_clear(&r); 33 } 34 35 int cmd__partial_clone(int argc, const char **argv) 36 { 37 setup_git_directory(the_repository); 38 39 if (argc < 4) 40 die("too few arguments"); 41 42 if (!strcmp(argv[1], "object-info")) 43 object_info(argv[2], argv[3]); 44 else 45 die("invalid argument '%s'", argv[1]); 46 47 return 0; 48 }