1/* 2 * GIT - The information manager from hell 3 * 4 * Copyright (C) Linus Torvalds, 2005 5 */ 6#include"cache.h" 7 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 */ 14intmain(int argc,char**argv) 15{ 16char*sha1_dir, *path; 17int len, i; 18 19if(mkdir(".git",0755) <0) { 20perror("unable to create .git directory"); 21exit(1); 22} 23 24 sha1_dir =getenv(DB_ENVIRONMENT); 25if(sha1_dir) { 26struct stat st; 27if(!stat(sha1_dir, &st) &&S_ISDIR(st.st_mode)) 28return0; 29fprintf(stderr,"DB_ENVIRONMENT set to bad directory%s: ", sha1_dir); 30} 31 32 sha1_dir = DEFAULT_DB_ENVIRONMENT; 33fprintf(stderr,"defaulting to private storage area\n"); 34 len =strlen(sha1_dir); 35if(mkdir(sha1_dir,0755) <0) { 36if(errno != EEXIST) { 37perror(sha1_dir); 38exit(1); 39} 40} 41 path =malloc(len +40); 42memcpy(path, sha1_dir, len); 43for(i =0; i <256; i++) { 44sprintf(path+len,"/%02x", i); 45if(mkdir(path,0755) <0) { 46if(errno != EEXIST) { 47perror(path); 48exit(1); 49} 50} 51} 52return0; 53}