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

Re: [PATCH 2/5] First step, making setup (somewhat) reentrant

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 7, 2008, 08:50 UTC
Message-ID
<alpine.LSU.1.00.0801070845270.10101@racer.site>
In-Reply-To
<1199684855-14246-2-git-send-email-ct@pipapo.org>
Hi,
[I assume that you mean this series post-1.5.4]
On Mon, 7 Jan 2008, Christian Thaeter wrote:
Show 13 quoted lines
> diff --git a/environment.c b/environment.c
> index 18a1c4e..492d87c 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -38,31 +38,48 @@ int auto_crlf = 0;	/* 1: both ways, -1: only when adding git objects */
>  unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
>  
>  /* This is set by setup_git_dir_gently() and/or git_default_config() */
> -char *git_work_tree_cfg;
> -static const char *work_tree;
> +char *git_work_tree_cfg = NULL;
> +static char *work_tree = NULL;
> +static int work_tree_initialized = 0;

Global variables do not need initialisation, if all what you do is set them to NULL. Therefore, most of this hunk is not necessary, and only distracts from what is really relevant, "work_tree_initialized = 0".

Show 7 quoted lines
>  static void setup_git_env(void)
>  {
>  	git_dir = getenv(GIT_DIR_ENVIRONMENT);
>  	if (!git_dir)
>  		git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
> +	if (git_object_dir)
> +		free(git_object_dir);
Logically, this belongs into a "cleanup_git_env()" function, no?
Show 5 quoted lines
>  	git_object_dir = getenv(DB_ENVIRONMENT);
> -	if (!git_object_dir) {
> +	if (git_object_dir) {
> +		git_object_dir = xstrdup(git_object_dir);
> +	}

Are you sure that you want to keep the object directory, even if you want to initialise to a new repository?

Which brings me to a more fundamental question: what do you need reentrant setup_directory() for? If it is just to allow multiple calls to that function for the _same_ repository, I say clean up your code.

Ciao, Dscho

Previous: Christian ThaeterNext: Junio C Hamano
Message 6 of 8 in “Add streq() to compat-util”
  1. 1/5 Add streq() to compat-utilChristian Thaeter, Jan 7, 2008
  2. 2/5 First step, making setup (somewhat) reentrantChristian Thaeter, Jan 7, 2008
  3. 3/5 provide a reset_packed_git() functionChristian Thaeter, Jan 7, 2008
  4. 4/5 Export some more functions to enable resetting the git stateChristian Thaeter, Jan 7, 2008
  5. 5/5 Make setup_git_directory reentrantChristian Thaeter, Jan 7, 2008
  6. Johannes SchindelinJan 7, 2008
  7. Junio C HamanoJan 7, 2008
  8. Johannes SchindelinJan 7, 2008

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.