"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: make it possible to ignore Git config file
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Sun, 24 Jul 2022 12:10:06 +0200

Download raw body.

Thread
On Sat, Jul 23, 2022 at 05:33:06PM +0200, Omar Polo wrote:
> there are two things to fix

> > +	if (getenv("GOT_IGNORE_GITCONFIG") != NULL) {
> > +		int i;
> > +
> > +		for (i = 0; i < repo->ngitconfig_remotes; i++) {
> > +			got_repo_free_remote_repo_data(
> > +			    &repo->gitconfig_remotes[i]);
> > +		}
> > +		free(repo->gitconfig_remotes);
> 
> needs to be set to NULL too to avoid a double free in got_repo_close
> (found the hard way)
> 
> > +		repo->ngitconfig_remotes = 0;
> > +
> > +		free(repo->gitconfig_author_name);
> > +		repo->gitconfig_author_name = NULL;
> > +		free(repo->gitconfig_author_email);
> > +		repo->gitconfig_author_email = NULL;
> 
> should reset also the global fields, otherwise it doesn't fix the issue
> with the test.

Thank you, ok stsp@

> diff /home/op/w/got
> commit - dd2ffb6aab71d23f9c6afaa547b597deed3f43ad
> path + /home/op/w/got
> blob - 5f060f8735c6ad9bc96ad7421ce6a62402cc7d5c
> file + lib/repository.c
> --- lib/repository.c
> +++ lib/repository.c
> @@ -687,12 +687,18 @@ read_gitconfig(struct got_repository *repo, const char
>  			    &repo->gitconfig_remotes[i]);
>  		}
>  		free(repo->gitconfig_remotes);
> +		repo->gitconfig_remotes = NULL;
>  		repo->ngitconfig_remotes = 0;
>  
>  		free(repo->gitconfig_author_name);
>  		repo->gitconfig_author_name = NULL;
>  		free(repo->gitconfig_author_email);
>  		repo->gitconfig_author_email = NULL;
> +
> +		free(repo->global_gitconfig_author_name);
> +		repo->global_gitconfig_author_name = NULL;
> +		free(repo->global_gitconfig_author_email);
> +		repo->global_gitconfig_author_email = NULL;
>  	}
>  
>  done:
> 
>