@@ -194,7 +194,7 @@ static void fill_sha1_path(char *pathbuf, const unsigned char *sha1)
194194 * DB_ENVIRONMENT environment variable if it is not found in
195195 * the primary object database.
196196 */
197- char * sha1_file_name (const unsigned char * sha1 )
197+ const char * sha1_file_name (const unsigned char * sha1 )
198198{
199199 static char buf [PATH_MAX ];
200200 const char * objdir ;
@@ -444,8 +444,7 @@ void prepare_alt_odb(void)
444444
445445static int has_loose_object_local (const unsigned char * sha1 )
446446{
447- char * name = sha1_file_name (sha1 );
448- return !access (name , F_OK );
447+ return !access (sha1_file_name (sha1 ), F_OK );
449448}
450449
451450int has_loose_object_nonlocal (const unsigned char * sha1 )
@@ -1420,17 +1419,15 @@ static int git_open_noatime(const char *name)
14201419
14211420static int stat_sha1_file (const unsigned char * sha1 , struct stat * st )
14221421{
1423- char * name = sha1_file_name (sha1 );
14241422 struct alternate_object_database * alt ;
14251423
1426- if (!lstat (name , st ))
1424+ if (!lstat (sha1_file_name ( sha1 ) , st ))
14271425 return 0 ;
14281426
14291427 prepare_alt_odb ();
14301428 errno = ENOENT ;
14311429 for (alt = alt_odb_list ; alt ; alt = alt -> next ) {
1432- name = alt -> name ;
1433- fill_sha1_path (name , sha1 );
1430+ fill_sha1_path (alt -> name , sha1 );
14341431 if (!lstat (alt -> base , st ))
14351432 return 0 ;
14361433 }
@@ -1441,18 +1438,16 @@ static int stat_sha1_file(const unsigned char *sha1, struct stat *st)
14411438static int open_sha1_file (const unsigned char * sha1 )
14421439{
14431440 int fd ;
1444- char * name = sha1_file_name (sha1 );
14451441 struct alternate_object_database * alt ;
14461442
1447- fd = git_open_noatime (name );
1443+ fd = git_open_noatime (sha1_file_name ( sha1 ) );
14481444 if (fd >= 0 )
14491445 return fd ;
14501446
14511447 prepare_alt_odb ();
14521448 errno = ENOENT ;
14531449 for (alt = alt_odb_list ; alt ; alt = alt -> next ) {
1454- name = alt -> name ;
1455- fill_sha1_path (name , sha1 );
1450+ fill_sha1_path (alt -> name , sha1 );
14561451 fd = git_open_noatime (alt -> base );
14571452 if (fd >= 0 )
14581453 return fd ;
@@ -2687,7 +2682,6 @@ void *read_sha1_file_extended(const unsigned char *sha1,
26872682 unsigned flag )
26882683{
26892684 void * data ;
2690- char * path ;
26912685 const struct packed_git * p ;
26922686 const unsigned char * repl = lookup_replace_object_extended (sha1 , flag );
26932687
@@ -2705,7 +2699,8 @@ void *read_sha1_file_extended(const unsigned char *sha1,
27052699 sha1_to_hex (repl ), sha1_to_hex (sha1 ));
27062700
27072701 if (has_loose_object (repl )) {
2708- path = sha1_file_name (sha1 );
2702+ const char * path = sha1_file_name (sha1 );
2703+
27092704 die ("loose object %s (stored in %s) is corrupt" ,
27102705 sha1_to_hex (repl ), path );
27112706 }
@@ -2903,10 +2898,9 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
29032898 git_zstream stream ;
29042899 git_SHA_CTX c ;
29052900 unsigned char parano_sha1 [20 ];
2906- char * filename ;
29072901 static char tmp_file [PATH_MAX ];
2902+ const char * filename = sha1_file_name (sha1 );
29082903
2909- filename = sha1_file_name (sha1 );
29102904 fd = create_tmpfile (tmp_file , sizeof (tmp_file ), filename );
29112905 if (fd < 0 ) {
29122906 if (errno == EACCES )
0 commit comments