setup: allow for prefix to be passed to git commands
In a future patch child processes which act on submodules need a little more context about the original command that was invoked. This patch teaches git to use the prefix stored in `GIT_INTERNAL_TOPLEVEL_PREFIX` instead of the prefix that was potentally found during the git directory setup process. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Mar 17, 2017 at 10:22 UTC
b58a68c1c1874ff155699d82947c9f026f431cb3
3 files changed
+7
-3
cache.h
+1
@@ -410,6 +410,7 @@ static inline enum object_type object_type(unsigned int mode)
410
#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
411
#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX"
412
#define GIT_SUPER_PREFIX_ENVIRONMENT "GIT_INTERNAL_SUPER_PREFIX"
413
+#define GIT_TOPLEVEL_PREFIX_ENVIRONMENT "GIT_INTERNAL_TOPLEVEL_PREFIX"
414
#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
415
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
416
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
git.c
-2
@@ -361,8 +361,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
361
if (!help && get_super_prefix()) {
362
if (!(p->option & SUPPORT_SUPER_PREFIX))
363
die("%s doesn't support --super-prefix", p->cmd);
364
- if (prefix)
365
- die("can't use --super-prefix from a subdirectory");
364
}
365
366
if (!help && p->option & NEED_WORK_TREE)
setup.c
+6
-1
@@ -939,9 +939,14 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
939
940
const char *setup_git_directory_gently(int *nongit_ok)
941
{
942
- const char *prefix;
942
+ const char *prefix, *env_prefix;
943
944
prefix = setup_git_directory_gently_1(nongit_ok);
945
+ env_prefix = getenv(GIT_TOPLEVEL_PREFIX_ENVIRONMENT);
946
+
947
+ if (env_prefix)
948
+ prefix = env_prefix;
949
+
950
if (prefix)
951
setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
952
else