2 * GIT - The information manager from hell
4 * Copyright (C) Linus Torvalds, 2005
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.
14 int main(int argc, char **argv)
16 char *sha1_dir, *path;
19 if (mkdir(".git", 0755) < 0) {
20 perror("unable to create .git directory");
24 sha1_dir = getenv(DB_ENVIRONMENT);
27 if (!stat(sha1_dir, &st) && S_ISDIR(st.st_mode))
29 fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
32 sha1_dir = DEFAULT_DB_ENVIRONMENT;
33 fprintf(stderr, "defaulting to private storage area\n");
34 len = strlen(sha1_dir);
35 if (mkdir(sha1_dir, 0755) < 0) {
36 if (errno != EEXIST) {
41 path = malloc(len + 40);
42 memcpy(path, sha1_dir, len);
43 for (i = 0; i < 256; i++) {
44 sprintf(path+len, "/%02x", i);
45 if (mkdir(path, 0755) < 0) {
46 if (errno != EEXIST) {