mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
[PATCH] init-db.c: normalize env var handling.
Normalize init-db environment variable handling, allowing the creation of object directories with something other than DEFAULT_DB_ENVIRONMENT. Signed-Off-By: Zach Welch <zw@superlucidity.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
4696cb93d1
commit
addb315d34
11
init-db.c
11
init-db.c
|
@ -22,15 +22,10 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
sha1_dir = getenv(DB_ENVIRONMENT);
|
sha1_dir = getenv(DB_ENVIRONMENT);
|
||||||
if (sha1_dir) {
|
if (!sha1_dir) {
|
||||||
struct stat st;
|
sha1_dir = DEFAULT_DB_ENVIRONMENT;
|
||||||
if (!stat(sha1_dir, &st) && S_ISDIR(st.st_mode))
|
fprintf(stderr, "defaulting to local storage area\n");
|
||||||
return 0;
|
|
||||||
fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sha1_dir = DEFAULT_DB_ENVIRONMENT;
|
|
||||||
fprintf(stderr, "defaulting to private storage area\n");
|
|
||||||
len = strlen(sha1_dir);
|
len = strlen(sha1_dir);
|
||||||
if (mkdir(sha1_dir, 0755) < 0) {
|
if (mkdir(sha1_dir, 0755) < 0) {
|
||||||
if (errno != EEXIST) {
|
if (errno != EEXIST) {
|
||||||
|
|
Loading…
Reference in a new issue