git-merge-cache -o does all the automerges in a single shot
[git/repo.git] / init-db.c
blobb6bb78356762bd28261949da54638f46776e6d4b
1 /*
2 * GIT - The information manager from hell
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 #include "cache.h"
8 void safe_create_dir(const char *dir)
10 if (mkdir(dir, 0755) < 0) {
11 if (errno != EEXIST) {
12 perror(dir);
13 exit(1);
19 * If you want to, you can share the DB area with any number of branches.
20 * That has advantages: you can save space by sharing all the SHA1 objects.
21 * On the other hand, it might just make lookup slower and messier. You
22 * be the judge. The default case is to have one DB per managed directory.
24 int main(int argc, char **argv)
26 const char *sha1_dir;
27 char *path;
28 int len, i;
30 sha1_dir = get_object_directory();
31 if (!gitenv(DB_ENVIRONMENT) && !gitenv(GIT_DIR_ENVIRONMENT)) {
32 /* We create leading paths only when we fall back
33 * to local .git/objects, at least for now.
35 safe_create_dir(DEFAULT_GIT_DIR_ENVIRONMENT);
36 fprintf(stderr, "defaulting to local storage area\n");
38 len = strlen(sha1_dir);
39 path = xmalloc(len + 40);
40 memcpy(path, sha1_dir, len);
42 safe_create_dir(sha1_dir);
43 for (i = 0; i < 256; i++) {
44 sprintf(path+len, "/%02x", i);
45 safe_create_dir(path);
47 return 0;