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

[PATCHv5 2/5] rev-parse: --local-env-vars option

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Feb 24, 2010, 23:34 UTC
Message-ID
<1267054458-11877-3-git-send-email-giuseppe.bilotta@gmail.com>
In-Reply-To
<1267054458-11877-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.g5b851b.dirty
Previous: Giuseppe BilottaNext: Heiko Voigt
Message 3 of 7 in “[PATCHv5 0/5] repo-local env vars handling”
  1. Giuseppe BilottaFeb 24, 2010
  2. 1/5 Refactor list of of repo-local env varsGiuseppe Bilotta, Feb 24, 2010
  3. 2/5 rev-parse: --local-env-vars optionGiuseppe Bilotta, Feb 24, 2010
  4. Heiko VoigtFeb 27, 2010
  5. 3/5 shell setup: clear_local_git_env() functionGiuseppe Bilotta, Feb 24, 2010
  6. 4/5 submodules: ensure clean environment when operating in a submoduleGiuseppe Bilotta, Feb 24, 2010
  7. 5/5 is_submodule_modified(): clear environment properlyGiuseppe Bilotta, Feb 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.