3 int main(int argc, char **argv)
5 char *sha1_dir = getenv(DB_ENVIRONMENT), *path;
8 if (mkdir(".dircache", 0700) < 0) {
9 perror("unable to create .dircache");
14 * If you want to, you can share the DB area with any number of branches.
15 * That has advantages: you can save space by sharing all the SHA1 objects.
16 * On the other hand, it might just make lookup slower and messier. You
19 sha1_dir = getenv(DB_ENVIRONMENT);
22 if (!stat(sha1_dir, &st) < 0 && S_ISDIR(st.st_mode))
24 fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
28 * The default case is to have a DB per managed directory.
30 sha1_dir = DEFAULT_DB_ENVIRONMENT;
31 fprintf(stderr, "defaulting to private storage area\n");
32 len = strlen(sha1_dir);
33 if (mkdir(sha1_dir, 0700) < 0) {
34 if (errno != EEXIST) {
39 path = malloc(len + 40);
40 memcpy(path, sha1_dir, len);
41 for (i = 0; i < 256; i++) {
42 sprintf(path+len, "/%02x", i);
43 if (mkdir(path, 0700) < 0) {
44 if (errno != EEXIST) {