]>
Commit | Line | Data |
---|---|---|
8bc9a0c7 LT |
1 | /* |
2 | * GIT - The information manager from hell | |
3 | * | |
4 | * Copyright (C) Linus Torvalds, 2005 | |
5 | */ | |
e83c5163 LT |
6 | #include "cache.h" |
7 | ||
cb126d8d ZW |
8 | void safe_create_dir(char *dir) |
9 | { | |
10 | if (mkdir(dir, 0755) < 0) { | |
11 | if (errno != EEXIST) { | |
12 | perror(dir); | |
13 | exit(1); | |
14 | } | |
15 | } | |
16 | } | |
17 | ||
4696cb93 ZW |
18 | /* |
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. | |
23 | */ | |
e83c5163 LT |
24 | int main(int argc, char **argv) |
25 | { | |
17cf7816 | 26 | char *sha1_dir, *path; |
19b2860c | 27 | int len, i; |
e83c5163 | 28 | |
cb126d8d | 29 | safe_create_dir(".git"); |
e83c5163 | 30 | |
e83c5163 | 31 | sha1_dir = getenv(DB_ENVIRONMENT); |
addb315d ZW |
32 | if (!sha1_dir) { |
33 | sha1_dir = DEFAULT_DB_ENVIRONMENT; | |
34 | fprintf(stderr, "defaulting to local storage area\n"); | |
e83c5163 | 35 | } |
e83c5163 | 36 | len = strlen(sha1_dir); |
e83c5163 LT |
37 | path = malloc(len + 40); |
38 | memcpy(path, sha1_dir, len); | |
cb126d8d ZW |
39 | |
40 | safe_create_dir(sha1_dir); | |
e83c5163 LT |
41 | for (i = 0; i < 256; i++) { |
42 | sprintf(path+len, "/%02x", i); | |
cb126d8d | 43 | safe_create_dir(path); |
e83c5163 LT |
44 | } |
45 | return 0; | |
46 | } |