Commit Diff


commit - 2c8899b952f67f90ab3a26b4331491832fe93c8a
commit + 3e0f95fc704e82b2b916e10c016299e1b49e8383
blob - ea412540fd202511367fedfbeaa5f864e0051758
blob + d97716d4af2c458376bb73bebfca2e1ff3725410
--- 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
blob + 5f060f8735c6ad9bc96ad7421ce6a62402cc7d5c
--- 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);
+		repo->ngitconfig_remotes = 0;
+
+		free(repo->gitconfig_author_name);
+		repo->gitconfig_author_name = NULL;
+		free(repo->gitconfig_author_email);
+		repo->gitconfig_author_email = NULL;
+	}
+
 done:
 	free(repo_gitconfig_path);
 	return err;