Re: [PATCH/POC 2/7] Add new environment variable $GIT_SUPER_DIR
From: Duy Nguyen <hidden>
Date: 2016-06-15 22:59:27
On Sat, Dec 14, 2013 at 1:12 AM, Junio C Hamano [off-list ref] wrote:
quoted
diff --git a/path.c b/path.c index eda9176..86a7c15 100644 --- a/path.c +++ b/path.c@@ -75,6 +75,16 @@ static void adjust_git_path(char *buf, int git_dir_len) strcpy(buf, get_index_file()); else if (git_db_env && dir_prefix(base, "objects")) replace_dir(buf, git_dir_len + 7, get_object_directory()); + else if (get_git_super_dir()) { + if (dir_prefix(base, "objects") || dir_prefix(base, "info") || + dir_prefix(base, "refs") || + (dir_prefix(base, "logs") && strcmp(base, "logs/HEAD")) || + dir_prefix(base, "rr-cache") || dir_prefix(base, "hooks") || + dir_prefix(base, "svn") || + !strcmp(base, "config") || !strcmp(base, "packed-refs") || + !strcmp(base, "shallow")) + replace_dir(buf, git_dir_len, get_git_super_dir()); + }This is essentially the list of what are shared across workdirs, right? I wonder if it is a bad idea to make everything under .git of the borrowed repository shared by default, with selected exceptions. Granted, not sharing by default is definitely safer than blindly sharing by default, so that alone may be a good argument to use a set of known-to-be-safe-to-share paths, like this code does.
The exception list could be equally long (most of them are *_HEAD). .git is also used for temporary files with mkstemp, but I think that's safe for sharing. What could break is when people add a new local *_HEAD and forget to update the exception list.
Don't we want .git/branches and .git/remotes shared? After all, their moral equivalents from .git/config are shared with the code.
Yes. I missed them. -- Duy