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-find-pack.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-find-pack.c` 53 lines ยท 1290 bytes Raw Blame History 1 #define USE_THE_REPOSITORY_VARIABLE 2 3 #include "test-tool.h" 4 #include "object-name.h" 5 #include "odb.h" 6 #include "packfile.h" 7 #include "parse-options.h" 8 #include "setup.h" 9 10 /* 11 * Display the path(s), one per line, of the packfile(s) containing 12 * the given object. 13 * 14 * If '--check-count ' is passed, then error out if the number of 15 * packfiles containing the object is not . 16 */ 17 18 static const char *const find_pack_usage[] = { 19 "test-tool find-pack [--check-count ] ", 20 NULL 21 }; 22 23 int cmd__find_pack(int argc, const char **argv) 24 { 25 struct object_id oid; 26 struct packed_git *p; 27 int count = -1, actual_count = 0; 28 const char *prefix = setup_git_directory(the_repository); 29 30 struct option options[] = { 31 OPT_INTEGER('c', "check-count", &count, "expected number of packs"), 32 OPT_END(), 33 }; 34 35 argc = parse_options(argc, argv, prefix, options, find_pack_usage, 0); 36 if (argc != 1) 37 usage(find_pack_usage[0]); 38 39 if (repo_get_oid(the_repository, argv[0], &oid)) 40 die("cannot parse %s as an object name", argv[0]); 41 42 repo_for_each_pack(the_repository, p) { 43 if (find_pack_entry_one(&oid, p)) { 44 printf("%s\n", p->pack_name); 45 actual_count++; 46 } 47 } 48 49 if (count > -1 && count != actual_count) 50 die("bad packfile count %d instead of %d", actual_count, count); 51 52 return 0; 53 }