-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jk/rev-parse-local-env-vars'
The "--local-env-vars" and "--resolve-git-dir" options of "git rev-parse" failed to work outside a repository when the command's option parsing was rewritten in 1.8.5 era. * jk/rev-parse-local-env-vars: rev-parse: let some options run outside repository t1515: add tests for rev-parse out-of-repo helpers
- Loading branch information
Showing
2 changed files
with
77 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
test_description='check that certain rev-parse options work outside repo' | ||
. ./test-lib.sh | ||
|
||
test_expect_success 'set up non-repo directory' ' | ||
GIT_CEILING_DIRECTORIES=$(pwd) && | ||
export GIT_CEILING_DIRECTORIES && | ||
mkdir non-repo && | ||
cd non-repo && | ||
# confirm that git does not find a repo | ||
test_must_fail git rev-parse --git-dir | ||
' | ||
|
||
# Rather than directly test the output of sq-quote directly, | ||
# make sure the shell can read back a tricky case, since | ||
# that's what we really care about anyway. | ||
tricky="really tricky with \\ and \" and '" | ||
dump_args () { | ||
for i in "$@"; do | ||
echo "arg: $i" | ||
done | ||
} | ||
test_expect_success 'rev-parse --sq-quote' ' | ||
dump_args "$tricky" easy >expect && | ||
eval "dump_args $(git rev-parse --sq-quote "$tricky" easy)" >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
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_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 && | ||
git rev-parse --resolve-git-dir dir/.git >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_done |