setup.h: move declarations for setup.c functions from cache.h
[git.git] / t / helper / test-partial-clone.c
blobcce496944ac002c0371463a4e9b4b8303f6a7083
1 #include "cache.h"
2 #include "hex.h"
3 #include "test-tool.h"
4 #include "repository.h"
5 #include "object-store.h"
6 #include "setup.h"
8 /*
9 * Prints the size of the object corresponding to the given hash in a specific
10 * gitdir. This is similar to "git -C gitdir cat-file -s", except that this
11 * exercises the code that accesses the object of an arbitrary repository that
12 * is not the_repository. ("git -C gitdir" makes it so that the_repository is
13 * the one in gitdir.)
15 static void object_info(const char *gitdir, const char *oid_hex)
17 struct repository r;
18 struct object_id oid;
19 unsigned long size;
20 struct object_info oi = {.sizep = &size};
21 const char *p;
23 if (repo_init(&r, gitdir, NULL))
24 die("could not init repo");
25 if (parse_oid_hex(oid_hex, &oid, &p))
26 die("could not parse oid");
27 if (oid_object_info_extended(&r, &oid, &oi, 0))
28 die("could not obtain object info");
29 printf("%d\n", (int) size);
32 int cmd__partial_clone(int argc, const char **argv)
34 setup_git_directory();
36 if (argc < 4)
37 die("too few arguments");
39 if (!strcmp(argv[1], "object-info"))
40 object_info(argv[2], argv[3]);
41 else
42 die("invalid argument '%s'", argv[1]);
44 return 0;