Re: [PATCH 1/2] core: use env variable instead of config var to turn on logging pack access
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 3, 2013, 20:24 UTC
- Message-ID
- <7vmwr7c59b.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1369921908-2988-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 24 quoted lines
> diff --git a/sha1_file.c b/sha1_file.c
> index 67e815b..7b47bdc 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -36,6 +36,8 @@ static inline uintmax_t sz_fmt(size_t s) { return s; }
>
> const unsigned char null_sha1[20];
>
> +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,6 +1958,14 @@ 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 = NULL;
> + if (!log_pack_access)
> + return;
> + }Have you ever tested this?
Once log_pack_access goes to NULL (e.g. when it sees the empty string it was initialized to), this new test will happily dereference NULL.