1 #define USE_THE_REPOSITORY_VARIABLE
4 #include "object-name.h"
5 #include "object-store.h"
7 #include "parse-options.h"
11 * Display the path(s), one per line, of the packfile(s) containing
14 * If '--check-count <n>' is passed, then error out if the number of
15 * packfiles containing the object is not <n>.
18 static const char *find_pack_usage
[] = {
19 "test-tool find-pack [--check-count <n>] <object>",
23 int cmd__find_pack(int argc
, const char **argv
)
27 int count
= -1, actual_count
= 0;
28 const char *prefix
= setup_git_directory();
30 struct option options
[] = {
31 OPT_INTEGER('c', "check-count", &count
, "expected number of packs"),
35 argc
= parse_options(argc
, argv
, prefix
, options
, find_pack_usage
, 0);
37 usage(find_pack_usage
[0]);
39 if (repo_get_oid(the_repository
, argv
[0], &oid
))
40 die("cannot parse %s as an object name", argv
[0]);
42 for (p
= get_all_packs(the_repository
); p
; p
= p
->next
)
43 if (find_pack_entry_one(oid
.hash
, p
)) {
44 printf("%s\n", p
->pack_name
);
48 if (count
> -1 && count
!= actual_count
)
49 die("bad packfile count %d instead of %d", actual_count
, count
);