aboutsummaryrefslogtreecommitdiffstats
path: root/environment.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2016-10-07 11:18:48 -0700
committerJunio C Hamano <gitster@pobox.com>2016-10-10 12:14:58 -0700
commit74866d75793559e8b351a17100679f83b96972ca (patch)
tree136607f717aac8848ec195727452df9296e18267 /environment.c
parent35f6318d44379452d8d33e880d8df0267b4a0cd0 (diff)
downloadgit-74866d75793559e8b351a17100679f83b96972ca.tar.gz
git: make super-prefix option
Add a super-prefix environment variable 'GIT_INTERNAL_SUPER_PREFIX' which can be used to specify a path from above a repository down to its root. When such a super-prefix is specified, the paths reported by Git are prefixed with it to make them relative to that directory "above". The paths given by the user on the command line (e.g. "git subcmd --output-file=path/to/a/file" and pathspecs) are taken relative to the directory "above" to match. The immediate use of this option is by commands which have a --recurse-submodule option in order to give context to submodules about how they were invoked. This option is currently only allowed for builtins which support a super-prefix. Signed-off-by: Brandon Williams <bmwill@google.com> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/environment.c b/environment.c
index ca72464a98..d12d7db20a 100644
--- a/environment.c
+++ b/environment.c
@@ -100,6 +100,8 @@ static char *work_tree;
static const char *namespace;
static size_t namespace_len;
+static const char *super_prefix;
+
static const char *git_dir, *git_common_dir;
static char *git_object_dir, *git_index_file, *git_graft_file;
int git_db_env, git_index_env, git_graft_env, git_common_dir_env;
@@ -120,6 +122,7 @@ const char * const local_repo_env[] = {
NO_REPLACE_OBJECTS_ENVIRONMENT,
GIT_REPLACE_REF_BASE_ENVIRONMENT,
GIT_PREFIX_ENVIRONMENT,
+ GIT_SUPER_PREFIX_ENVIRONMENT,
GIT_SHALLOW_FILE_ENVIRONMENT,
GIT_COMMON_DIR_ENVIRONMENT,
NULL
@@ -222,6 +225,16 @@ const char *strip_namespace(const char *namespaced_ref)
return namespaced_ref + namespace_len;
}
+const char *get_super_prefix(void)
+{
+ static int initialized;
+ if (!initialized) {
+ super_prefix = getenv(GIT_SUPER_PREFIX_ENVIRONMENT);
+ initialized = 1;
+ }
+ return super_prefix;
+}
+
static int git_work_tree_initialized;
/*