summaryrefslogtreecommitdiff
path: root/t/t1515-rev-parse-outside-repo.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-02-29 11:01:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-29 17:24:47 (GMT)
commitfc7d47f0dd4f041af2ed2004700f18b635f3b204 (patch)
treed41e5fcb4f10c3e12497dea3940ac33234abcd23 /t/t1515-rev-parse-outside-repo.sh
parenta4e21fb4dc0ee1783b94be78fd91b73df18992f3 (diff)
downloadgit-fc7d47f0dd4f041af2ed2004700f18b635f3b204.zip
git-fc7d47f0dd4f041af2ed2004700f18b635f3b204.tar.gz
git-fc7d47f0dd4f041af2ed2004700f18b635f3b204.tar.bz2
rev-parse: let some options run outside repository
Once upon a time, you could use "--local-env-vars" and "--resolve-git-dir" outside of any git repository, but they had to come first on the command line. Commit 68889b4 (rev-parse: remove restrictions on some options, 2013-07-21) put them into the normal option-parsing loop, fixing the latter. But it inadvertently broke the former, as we call setup_git_directory() before starting that loop. We can note that those options don't care even conditionally about whether we are in a git repo. So it's fine if we simply wait to setup the repo until we see an option that needs it. However, there is one special exception we should make: historically, rev-parse will set up the repository and read config even if there are _no_ options. Some of the tests in t1300 rely on this to check "git -c $config" parsing. That's not mirroring real-world use, and we could tweak the test. But t0002 uses a bare "git rev-parse" to check "are we in a git repository?". It's plausible that real-world scripts are relying on this. So let's cover this case specially, and treat an option-less "rev-parse" as "see if we're in a repo". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1515-rev-parse-outside-repo.sh')
-rwxr-xr-xt/t1515-rev-parse-outside-repo.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/t/t1515-rev-parse-outside-repo.sh b/t/t1515-rev-parse-outside-repo.sh
index ae33093..3ec2971 100755
--- a/t/t1515-rev-parse-outside-repo.sh
+++ b/t/t1515-rev-parse-outside-repo.sh
@@ -27,14 +27,14 @@ test_expect_success 'rev-parse --sq-quote' '
test_cmp expect actual
'
-test_expect_failure 'rev-parse --local-env-vars' '
+test_expect_success 'rev-parse --local-env-vars' '
git rev-parse --local-env-vars >actual &&
# we do not want to depend on the complete list here,
# so just look for something plausible
grep ^GIT_DIR actual
'
-test_expect_failure 'rev-parse --resolve-git-dir' '
+test_expect_success 'rev-parse --resolve-git-dir' '
git init --separate-git-dir repo dir &&
test_must_fail git rev-parse --resolve-git-dir . &&
echo "$(pwd)/repo" >expect &&