diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-06-21 03:02:28 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-06-21 03:02:28 +0400 |
commit | 8f0c843aab226225b8ef43e9b2e317bda5ea8f6d (patch) | |
tree | 85ae7766a7068daafb39ce1088012f780303252a /sha1_file.c | |
parent | 01c0615dceb433a5498c7160d67f77a6cc9197bb (diff) | |
parent | 1dd278ce60294aa6b3119a469007949c6fde425a (diff) |
Merge branch 'nd/traces'
* nd/traces:
git.txt: document GIT_TRACE_PACKET
core: use env variable instead of config var to turn on logging pack access
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c index 5c08701ae8..16f08d475c 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -36,6 +36,9 @@ static inline uintmax_t sz_fmt(size_t s) { return s; } const unsigned char null_sha1[20]; +static const char *no_log_pack_access = "no_log_pack_access"; +static const char *log_pack_access; + /* * This is meant to hold a *small* number of objects that you would * 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) { static FILE *log_file; + if (!log_pack_access) + log_pack_access = getenv("GIT_TRACE_PACK_ACCESS"); + if (!log_pack_access) + log_pack_access = no_log_pack_access; + if (log_pack_access == no_log_pack_access) + return; + if (!log_file) { log_file = fopen(log_pack_access, "w"); if (!log_file) { error("cannot open pack access log '%s' for writing: %s", log_pack_access, strerror(errno)); - log_pack_access = NULL; + log_pack_access = no_log_pack_access; return; } } @@ -1992,7 +2002,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset, int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC; int base_from_cache = 0; - if (log_pack_access) + if (log_pack_access != no_log_pack_access) write_pack_access_log(p, obj_offset); /* PHASE 1: drill down to the innermost base object */ |