Download raw body.
make it possible to ignore Git config file
Stefan Sperling <stsp@stsp.name> wrote: > Omar found a test failure in test_rebase_no_author_info(), where the > author from ~/.gitconfig will be used instead of having no author set. > > This patch adds a switch we can use to ignore Git configuration settings. > Git's config file contains some data we must not ignore, such as the > repository format version (smart idea to store this in the user-facing > config file, isn't it), and any enabled repository format extensions > (if any of them are enabled then we must not touch the repository). > > Once this is in, we can fix test_rebase_no_author_info() by setting > this variable. It might also be useful in other situations, so I decided > to document it instead of making it a hidden setting. > > ok? i've ok'd this too fast, sorry. there are two things to fix > diff /home/stsp/src/got > commit - 2c8899b952f67f90ab3a26b4331491832fe93c8a > path + /home/stsp/src/got > blob - ea412540fd202511367fedfbeaa5f864e0051758 > file + got/got.1 > --- got/got.1 > +++ got/got.1 > @@ -2750,7 +2750,7 @@ argument corresponds to the work tree's root directory > for all tracked files. > .El > .Sh ENVIRONMENT > -.Bl -tag -width GOT_AUTHOR > +.Bl -tag -width GOT_IGNORE_GITCONFIG > .It Ev GOT_AUTHOR > The author's name and email address, such as > .Dq An Flan Hacker Aq Mt flan_hacker@openbsd.org . > @@ -2806,6 +2806,9 @@ The default limit on the number of commits traversed b > .Cm got log . > If set to zero, the limit is unbounded. > This variable will be silently ignored if it is set to a non-numeric value. > +.It Ev GOT_IGNORE_GITCONFIG > +If this variable is set then any remote repository definitions or author > +information found in Git configuration files will be ignored. > .El > .Sh FILES > .Bl -tag -width packed-refs -compact > blob - c16937331653c5414c3a3ed0215a2b9f3193f106 > file + lib/repository.c > --- lib/repository.c > +++ lib/repository.c > @@ -678,6 +678,23 @@ read_gitconfig(struct got_repository *repo, const char > repo_gitconfig_path); > if (err) > goto done; > + > + 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. > + } > + > done: > free(repo_gitconfig_path); > return err; 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:
make it possible to ignore Git config file