1/* 2 * GIT - The information manager from hell 3 * 4 * Copyright (C) Linus Torvalds, 2005 5 */ 6#include"cache.h" 7 8intmain(int argc,char**argv) 9{ 10char*sha1_dir, *path; 11int len, i; 12 13if(mkdir(".git",0755) <0) { 14perror("unable to create .git directory"); 15exit(1); 16} 17 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. 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/* 33 * The default case is to have a DB per managed directory. 34 */ 35 sha1_dir = DEFAULT_DB_ENVIRONMENT; 36fprintf(stderr,"defaulting to private storage area\n"); 37 len =strlen(sha1_dir); 38if(mkdir(sha1_dir,0755) <0) { 39if(errno != EEXIST) { 40perror(sha1_dir); 41exit(1); 42} 43} 44 path =malloc(len +40); 45memcpy(path, sha1_dir, len); 46for(i =0; i <256; i++) { 47sprintf(path+len,"/%02x", i); 48if(mkdir(path,0755) <0) { 49if(errno != EEXIST) { 50perror(path); 51exit(1); 52} 53} 54} 55return0; 56}