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

[PATCHv4 3/6] rev-parse: --local-env-vars option

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Feb 24, 2010, 07:23 UTC
Message-ID
<1266996196-25978-4-git-send-email-giuseppe.bilotta@gmail.com>
In-Reply-To
<1266996196-25978-1-git-send-email-giuseppe.bilotta@gmail.com>
This prints the list of repo-local environment variables.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/git-rev-parse.txt |    6 ++++++
 builtin-rev-parse.c             |    8 ++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 1a613aa..8db600f 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -148,6 +148,12 @@ shown.  If the pattern does not contain a globbing character (`?`,
 --is-bare-repository::
 	When the repository is bare print "true", otherwise "false".
 
+--local-env-vars::
+	List the GIT_* environment variables that are local to the
+	repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
+	Only the names of the variables are listed, not their value,
+	even if they are set.
+
 --short::
 --short=number::
 	Instead of outputting the full SHA1 values of object names try to
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index a8c5043..ab7b520 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -455,7 +455,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 	if (argc > 1 && !strcmp("--sq-quote", argv[1]))
 		return cmd_sq_quote(argc - 2, argv + 2);
 
+	if (argc > 0 && !strcmp("--local-env-vars", argv[1])) {
+		unsigned int i = 0;
+		const char *var;
+		while (var = local_repo_env[i++])
+			printf("%s\n", var);
+		return 0;
+	}
 	if (argc > 1 && !strcmp("-h", argv[1]))
+
 		usage(builtin_rev_parse_usage);
 
 	prefix = setup_git_directory();
-- 
1.7.0.212.g4e217.dirty
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 8 of 15 in “[PATCHv4 0/6] repo-local env vars handling”
  1. Giuseppe BilottaFeb 24, 2010
  2. 1/6 environment: static list of repo-local env varsGiuseppe Bilotta, Feb 24, 2010
  3. Junio C HamanoFeb 24, 2010
  4. Giuseppe BilottaFeb 24, 2010
  5. Junio C HamanoFeb 24, 2010
  6. Giuseppe BilottaFeb 24, 2010
  7. 2/6 connect: use static list of repo-local env varsGiuseppe Bilotta, Feb 24, 2010
  8. 3/6 rev-parse: --local-env-vars optionGiuseppe Bilotta, Feb 24, 2010
  9. 4/6 shell setup: clear_local_git_env() functionGiuseppe Bilotta, Feb 24, 2010
  10. 5/6 submodules: ensure clean environment when operating in a submoduleGiuseppe Bilotta, Feb 24, 2010
  11. 6/6 is_submodule_modified(): clear environment properlyGiuseppe Bilotta, Feb 24, 2010
  12. Johannes SixtFeb 24, 2010
  13. Giuseppe BilottaFeb 24, 2010
  14. Johannes SixtFeb 24, 2010
  15. Giuseppe BilottaFeb 24, 2010

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.