git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 6 in “core: use env variable instead of config var to turn on logging pack access”
  1. 1/2 core: use env variable instead of config var to turn on logging pack accessNguyễn Thái Ngọc Duy, May 30, 2013
  2. 2/2 git.txt: document GIT_TRACE_PACKETNguyễn Thái Ngọc Duy, May 30, 2013
  3. Junio C HamanoJun 3, 2013
  4. core: use env variable instead of config var to turn on logging pack accessNguyễn Thái Ngọc Duy, Jun 3, 2013
  5. Junio C HamanoJun 4, 2013
  6. Duy NguyenJun 4, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.