1 /*
2 * GIT - The information manager from hell
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 #include "cache.h"
8 /*
9 * If you want to, you can share the DB area with any number of branches.
10 * That has advantages: you can save space by sharing all the SHA1 objects.
11 * On the other hand, it might just make lookup slower and messier. You
12 * be the judge. The default case is to have one DB per managed directory.
13 */
14 int main(int argc, char **argv)
15 {
16 char *sha1_dir, *path;
17 int len, i;
19 if (mkdir(".git", 0755) < 0) {
20 perror("unable to create .git directory");
21 exit(1);
22 }
24 sha1_dir = getenv(DB_ENVIRONMENT);
25 if (!sha1_dir) {
26 sha1_dir = DEFAULT_DB_ENVIRONMENT;
27 fprintf(stderr, "defaulting to local storage area\n");
28 }
29 len = strlen(sha1_dir);
30 if (mkdir(sha1_dir, 0755) < 0) {
31 if (errno != EEXIST) {
32 perror(sha1_dir);
33 exit(1);
34 }
35 }
36 path = malloc(len + 40);
37 memcpy(path, sha1_dir, len);
38 for (i = 0; i < 256; i++) {
39 sprintf(path+len, "/%02x", i);
40 if (mkdir(path, 0755) < 0) {
41 if (errno != EEXIST) {
42 perror(path);
43 exit(1);
44 }
45 }
46 }
47 return 0;
48 }