Re: [PATCH v2] config: allow inaccessible configuration under $HOME
- From
Jason A. Donenfeld <jason@zx2c4.com>
- Date
- May 25, 2013, 11:35 UTC
- Message-ID
- <CAHmME9rYH2kuvxafg10kYRa8kiOLeBeY9UuwUMNOeQdTbvhf+g@mail.gmail.com>
- In-Reply-To
- <20130412210318.GU27070@google.com>
Jonathan's patch would indeed be nice. In cgit, we are forced to do ugly things like this:
/* Do not look in /etc/ for gitconfig and gitattributes. */
setenv("GIT_CONFIG_NOSYSTEM", "1", 1);
setenv("GIT_ATTR_NOSYSTEM", "1", 1); /* We unset HOME and XDG_CONFIG_HOME before calling the git
setup function
* so that we don't make unneccessary filesystem accesses. */
user_home = getenv("HOME");
xdg_home = getenv("XDG_CONFIG_HOME");
unsetenv("HOME");
unsetenv("XDG_CONFIG_HOME"); /* Setup the git directory and initialize the notes system.
Both of these
* load local configuration from the git repository, so we do
them both while
* the HOME variables are unset. */
setup_git_directory_gently(&nongit);
init_display_notes(NULL); /* We restore the unset variables afterward. */
if (user_home)
setenv("HOME", user_home, 1);
if (xdg_home)
setenv("XDG_CONFIG_HOME", xdg_home, 1);A big nasty guard around the git setup function, so that we don't error out.