]>
git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-find-pack.c
2 #include "object-name.h"
3 #include "object-store.h"
5 #include "parse-options.h"
9 * Display the path(s), one per line, of the packfile(s) containing
12 * If '--check-count <n>' is passed, then error out if the number of
13 * packfiles containing the object is not <n>.
16 static const char *find_pack_usage
[] = {
17 "test-tool find-pack [--check-count <n>] <object>",
21 int cmd__find_pack(int argc
, const char **argv
)
25 int count
= -1, actual_count
= 0;
26 const char *prefix
= setup_git_directory();
28 struct option options
[] = {
29 OPT_INTEGER('c', "check-count", &count
, "expected number of packs"),
33 argc
= parse_options(argc
, argv
, prefix
, options
, find_pack_usage
, 0);
35 usage(find_pack_usage
[0]);
37 if (repo_get_oid(the_repository
, argv
[0], &oid
))
38 die("cannot parse %s as an object name", argv
[0]);
40 for (p
= get_all_packs(the_repository
); p
; p
= p
->next
)
41 if (find_pack_entry_one(oid
.hash
, p
)) {
42 printf("%s\n", p
->pack_name
);
46 if (count
> -1 && count
!= actual_count
)
47 die("bad packfile count %d instead of %d", actual_count
, count
);