@@ -36,6 +36,9 @@ static inline uintmax_t sz_fmt(size_t s) { return s; }
3636
3737const unsigned char null_sha1 [20 ];
3838
39+ static const char * no_log_pack_access = "no_log_pack_access" ;
40+ static const char * log_pack_access ;
41+
3942/*
4043 * This is meant to hold a *small* number of objects that you would
4144 * want read_sha1_file() to be able to return, but yet you do not want
@@ -1956,12 +1959,19 @@ static void write_pack_access_log(struct packed_git *p, off_t obj_offset)
19561959{
19571960 static FILE * log_file ;
19581961
1962+ if (!log_pack_access )
1963+ log_pack_access = getenv ("GIT_TRACE_PACK_ACCESS" );
1964+ if (!log_pack_access )
1965+ log_pack_access = no_log_pack_access ;
1966+ if (log_pack_access == no_log_pack_access )
1967+ return ;
1968+
19591969 if (!log_file ) {
19601970 log_file = fopen (log_pack_access , "w" );
19611971 if (!log_file ) {
19621972 error ("cannot open pack access log '%s' for writing: %s" ,
19631973 log_pack_access , strerror (errno ));
1964- log_pack_access = NULL ;
1974+ log_pack_access = no_log_pack_access ;
19651975 return ;
19661976 }
19671977 }
@@ -1992,7 +2002,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
19922002 int delta_stack_nr = 0 , delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC ;
19932003 int base_from_cache = 0 ;
19942004
1995- if (log_pack_access )
2005+ if (log_pack_access != no_log_pack_access )
19962006 write_pack_access_log (p , obj_offset );
19972007
19982008 /* PHASE 1: drill down to the innermost base object */
0 commit comments