diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2017-02-14 15:36:19 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-14 13:14:00 -0800 |
commit | 4b0c3c7735716e8e1faba9a25b4aebf019d8570a (patch) | |
tree | acc4d0467da6cc84066c781b7a739562e3497c06 /t/t4034/java | |
parent | remote: avoid reading $GIT_DIR config in non-repo (diff) | |
download | tgif-4b0c3c7735716e8e1faba9a25b4aebf019d8570a.tar.xz |
remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
To push from or fetch to the current repository, remote helpers need
to know what repository that is. Accordingly, Git sets the GIT_DIR
environment variable to the path to the current repository when
invoking remote helpers.
There is a special case it does not handle: "git ls-remote" and "git
archive --remote" can be run to inspect a remote repository without
being run from any local repository. GIT_DIR is not useful in this
scenario:
- if we are not in a repository, we don't need to set GIT_DIR to
override an existing GIT_DIR value from the environment. If GIT_DIR
is present then we would be in a repository if it were valid and
would have called die() if it weren't.
- not setting GIT_DIR may cause a helper to do the usual discovery
walk to find the repository. But we know we're not in one, or we
would have found it ourselves. So in the worst case it may expend
a little extra effort to try to find a repository and fail (for
example, remote-curl would do this to try to find repository-level
configuration).
So leave GIT_DIR unset in this case. This makes GIT_DIR easier to
understand for remote helper authors and makes transport code less of
a special case for repository discovery.
Noticed using b1ef400e (setup_git_env: avoid blind fall-back to
".git", 2016-10-20) from 'next':
$ cd /tmp
$ git ls-remote https://kernel.googlesource.com/pub/scm/git/git
fatal: BUG: setup_git_env called without repository
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4034/java')
0 files changed, 0 insertions, 0 deletions