1/* 2 * GIT - The information manager from hell 3 * 4 * Copyright (C) Linus Torvalds, 2005 5 */ 6#include"cache.h" 7 8voidsafe_create_dir(const char*dir) 9{ 10if(mkdir(dir,0755) <0) { 11if(errno != EEXIST) { 12perror(dir); 13exit(1); 14} 15} 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. The default case is to have one DB per managed directory. 23 */ 24intmain(int argc,char**argv) 25{ 26const char*sha1_dir; 27char*path; 28int len, i; 29 30 sha1_dir =get_object_directory(); 31if(!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. 34 */ 35safe_create_dir(DEFAULT_GIT_DIR_ENVIRONMENT); 36fprintf(stderr,"defaulting to local storage area\n"); 37} 38 len =strlen(sha1_dir); 39 path =xmalloc(len +40); 40memcpy(path, sha1_dir, len); 41 42safe_create_dir(sha1_dir); 43for(i =0; i <256; i++) { 44sprintf(path+len,"/%02x", i); 45safe_create_dir(path); 46} 47return0; 48}