{"thread":{"id":"42375","subject":"[PATCH v3 0/5] modernize t1500","startedAt":"2016-05-18T20:15:40Z","lastAt":"2016-05-18T20:15:45Z","messageCount":6,"participants":["Eric Sunshine"],"isPatch":true,"patchVersion":3,"patchTotal":5},"messages":[{"id":"286921","messageId":"20160518201545.9113-1-sunshine@sunshineco.com","threadId":"42375","inReplyTo":null,"subject":"[PATCH v3 0/5] modernize t1500","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-18T20:15:40Z","receivedAt":"2016-05-18T20:15:40Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"This is a re-roll of [1] which modernizes t1500 by updating tests to set\nup their own needed state rather than relying upon manipulation of\nglobal state.\n\nChanges since v2[1]:\n\nAvoid POSIX ${dir:+-C \"$dir\"} since some older broken shells incorrectly\nexpand this to a single argument (\"-C <dir>\") rather than the expected\ntwo (-C and \"<dir>\"). Thanks to Peff and SZEDER for providing links to\nprevious reports of this problem[2][3].\n\nInclude the leading dashes in option names iterated over by the for-loop\nin test_rev_parse() to potentially make it easier for some future change\nto specify multiple options at once to git-rev-parse (SZEDER's\nexample[4] was \"git rev-parse --absolute-path --git-dir\").\n\nA v2 to v3 interdiff is included below.\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/294902\n[2]: http://thread.gmane.org/gmane.comp.version-control.git/294902/focus=294916\n[3]: http://thread.gmane.org/gmane.comp.version-control.git/294902/focus=294923\n[4]: http://thread.gmane.org/gmane.comp.version-control.git/294902/focus=294971\n\nEric Sunshine (5):\n  t1500: be considerate to future potential tests\n  t1500: test_rev_parse: facilitate future test enhancements\n  t1500: avoid changing working directory outside of tests\n  t1500: avoid setting configuration options outside of tests\n  t1500: avoid setting environment variables outside of tests\n\n t/t1500-rev-parse.sh | 123 ++++++++++++++++++++++++++-------------------------\n 1 file changed, 63 insertions(+), 60 deletions(-)\n\n--- >8 ---\ndiff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh\nindex 39af565..038e24c 100755\n--- a/t/t1500-rev-parse.sh\n+++ b/t/t1500-rev-parse.sh\n@@ -5,13 +5,13 @@ test_description='test git rev-parse'\n \n # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir\n test_rev_parse () {\n-\tdir=\n+\td=\n \tbare=\n \tgitdir=\n \twhile :\n \tdo\n \t\tcase \"$1\" in\n-\t\t-C) dir=\"$2\"; shift; shift ;;\n+\t\t-C) d=\"$2\"; shift; shift ;;\n \t\t-b) case \"$2\" in\n \t\t    [tfu]*) bare=\"$2\"; shift; shift ;;\n \t\t    *) error \"test_rev_parse: bogus core.bare value '$2'\" ;;\n@@ -25,11 +25,11 @@ test_rev_parse () {\n \tname=$1\n \tshift\n \n-\tfor o in is-bare-repository \\\n-\t\t is-inside-git-dir \\\n-\t\t is-inside-work-tree \\\n-\t\t show-prefix \\\n-\t\t git-dir\n+\tfor o in --is-bare-repository \\\n+\t\t --is-inside-git-dir \\\n+\t\t --is-inside-work-tree \\\n+\t\t --show-prefix \\\n+\t\t --git-dir\n \tdo\n \t\ttest $# -eq 0 && break\n \t\texpect=\"$1\"\n@@ -42,13 +42,13 @@ test_rev_parse () {\n \t\t\tfi &&\n \n \t\t\tcase \"$bare\" in\n-\t\t\tt*) test_config ${dir:+-C \"$dir\"} core.bare true ;;\n-\t\t\tf*) test_config ${dir:+-C \"$dir\"} core.bare false ;;\n-\t\t\tu*) test_unconfig ${dir:+-C \"$dir\"} core.bare ;;\n+\t\t\tt*) test_config ${d:+-C} ${d:+\"$d\"} core.bare true ;;\n+\t\t\tf*) test_config ${d:+-C} ${d:+\"$d\"} core.bare false ;;\n+\t\t\tu*) test_unconfig ${d:+-C} ${d:+\"$d\"} core.bare ;;\n \t\t\tesac &&\n \n \t\t\techo \"$expect\" >expect &&\n-\t\t\tgit ${dir:+-C \"$dir\"} rev-parse --$o >actual &&\n+\t\t\tgit ${d:+-C} ${d:+\"$d\"} rev-parse $o >actual &&\n \t\t\ttest_cmp expect actual\n \t\t'\n \t\tshift\n--- >8 ---\n\n-- \n2.8.2.748.g927f425\n"},{"id":"289395","messageId":"20160518201545.9113-2-sunshine@sunshineco.com","threadId":"42375","inReplyTo":"20160518201545.9113-1-sunshine@sunshineco.com","subject":"[PATCH v3 1/5] t1500: be considerate to future potential tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-18T20:15:41Z","receivedAt":"2016-05-18T20:15:41Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"The final batch of git-rev-parse tests work against a non-local object\ndatabase named repo.git. This is done by renaming .git to repo.git and\npointing GIT_DIR at it, but the name is never restored to .git at the\nend of the script, which can be problematic for tests added in the\nfuture. Be more friendly by instead making repo.git a copy of .git.\n\nFurthermore, make it clear that tests in repo.git will be independent\nfrom the results of earlier tests done in .git by initializing repo.git\nearlier in the test sequence.\n\nLikewise, bundle remaining preparation (such as directory creation) into\na common setup test consistent with modern practice.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/t1500-rev-parse.sh | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh\nindex 48ee077..0194f54 100755\n--- a/t/t1500-rev-parse.sh\n+++ b/t/t1500-rev-parse.sh\n@@ -37,6 +37,11 @@ test_rev_parse() {\n \n ROOT=$(pwd)\n \n+test_expect_success 'setup' '\n+\tmkdir -p sub/dir work &&\n+\tcp -R .git repo.git\n+'\n+\n test_rev_parse toplevel false false true '' .git\n \n cd .git || exit 1\n@@ -45,7 +50,6 @@ cd objects || exit 1\n test_rev_parse .git/objects/ false true false '' \"$ROOT/.git\"\n cd ../.. || exit 1\n \n-mkdir -p sub/dir || exit 1\n cd sub/dir || exit 1\n test_rev_parse subdirectory false false true sub/dir/ \"$ROOT/.git\"\n cd ../.. || exit 1\n@@ -56,7 +60,6 @@ test_rev_parse 'core.bare = true' true false false\n git config --unset core.bare\n test_rev_parse 'core.bare undefined' false false true\n \n-mkdir work || exit 1\n cd work || exit 1\n GIT_DIR=../.git\n GIT_CONFIG=\"$(pwd)\"/../.git/config\n@@ -71,7 +74,6 @@ test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''\n git config --unset core.bare\n test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''\n \n-mv ../.git ../repo.git || exit 1\n GIT_DIR=../repo.git\n GIT_CONFIG=\"$(pwd)\"/../repo.git/config\n \n-- \n2.8.2.748.g927f425\n\n"},{"id":"286924","messageId":"20160518201545.9113-3-sunshine@sunshineco.com","threadId":"42375","inReplyTo":"20160518201545.9113-1-sunshine@sunshineco.com","subject":"[PATCH v3 2/5] t1500: test_rev_parse: facilitate future test enhancements","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-18T20:15:42Z","receivedAt":"2016-05-18T20:15:42Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Tests run by test_rev_parse() are nearly identical; each invokes\ngit-rev-parse with a single option and compares the result against an\nexpected value. Such duplication makes it onerous to extend the tests\nsince any change needs to be repeated in each test. Avoid the\nduplication by parameterizing the test and driving it via a for-loop.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/t1500-rev-parse.sh | 44 +++++++++++++++++---------------------------\n 1 file changed, 17 insertions(+), 27 deletions(-)\n\ndiff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh\nindex 0194f54..ecc575b 100755\n--- a/t/t1500-rev-parse.sh\n+++ b/t/t1500-rev-parse.sh\n@@ -3,38 +3,28 @@\n test_description='test git rev-parse'\n . ./test-lib.sh\n \n-test_rev_parse() {\n+# usage: label is-bare is-inside-git is-inside-work prefix git-dir\n+test_rev_parse () {\n \tname=$1\n \tshift\n \n-\ttest_expect_success \"$name: is-bare-repository\" \\\n-\t\"test '$1' = \\\"\\$(git rev-parse --is-bare-repository)\\\"\"\n-\tshift\n-\t[ $# -eq 0 ] && return\n-\n-\ttest_expect_success \"$name: is-inside-git-dir\" \\\n-\t\"test '$1' = \\\"\\$(git rev-parse --is-inside-git-dir)\\\"\"\n-\tshift\n-\t[ $# -eq 0 ] && return\n-\n-\ttest_expect_success \"$name: is-inside-work-tree\" \\\n-\t\"test '$1' = \\\"\\$(git rev-parse --is-inside-work-tree)\\\"\"\n-\tshift\n-\t[ $# -eq 0 ] && return\n-\n-\ttest_expect_success \"$name: prefix\" \\\n-\t\"test '$1' = \\\"\\$(git rev-parse --show-prefix)\\\"\"\n-\tshift\n-\t[ $# -eq 0 ] && return\n-\n-\ttest_expect_success \"$name: git-dir\" \\\n-\t\"test '$1' = \\\"\\$(git rev-parse --git-dir)\\\"\"\n-\tshift\n-\t[ $# -eq 0 ] && return\n+\tfor o in --is-bare-repository \\\n+\t\t --is-inside-git-dir \\\n+\t\t --is-inside-work-tree \\\n+\t\t --show-prefix \\\n+\t\t --git-dir\n+\tdo\n+\t\ttest $# -eq 0 && break\n+\t\texpect=\"$1\"\n+\t\ttest_expect_success \"$name: $o\" '\n+\t\t\techo \"$expect\" >expect &&\n+\t\t\tgit rev-parse $o >actual &&\n+\t\t\ttest_cmp expect actual\n+\t\t'\n+\t\tshift\n+\tdone\n }\n \n-# label is-bare is-inside-git is-inside-work prefix git-dir\n-\n ROOT=$(pwd)\n \n test_expect_success 'setup' '\n-- \n2.8.2.748.g927f425\n"},{"id":"286925","messageId":"20160518201545.9113-4-sunshine@sunshineco.com","threadId":"42375","inReplyTo":"20160518201545.9113-1-sunshine@sunshineco.com","subject":"[PATCH v3 3/5] t1500: avoid changing working directory outside of tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-18T20:15:43Z","receivedAt":"2016-05-18T20:15:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Ideally, each test should be responsible for setting up state it needs\nrather than relying upon transient global state. Toward this end, teach\ntest_rev_parse() to accept a \"-C <dir>\" option to allow callers to\ninstruct it explicitly in which directory its tests should be run. Take\nadvantage of this new option to avoid changing the working directory\noutside of tests.\n\nImplementation note: test_rev_parse() passes \"-C <dir>\" along to\ngit-rev-parse with <dir> properly quoted. The natural and POSIX way to\ndo so is via ${dir:+-C \"$dir\"}, however, with some older broken shells,\nthis expression evaluates incorrectly to a single argument (\"-C <dir>\")\nrather than the expected two (-C and \"<dir>\"). Work around this problem\nwith the slightly ungainly expression: ${dir:+-C} ${dir:+\"$dir\"}\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/t1500-rev-parse.sh | 42 +++++++++++++++++++++++-------------------\n 1 file changed, 23 insertions(+), 19 deletions(-)\n\ndiff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh\nindex ecc575b..d73a52b 100755\n--- a/t/t1500-rev-parse.sh\n+++ b/t/t1500-rev-parse.sh\n@@ -3,8 +3,18 @@\n test_description='test git rev-parse'\n . ./test-lib.sh\n \n-# usage: label is-bare is-inside-git is-inside-work prefix git-dir\n+# usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir\n test_rev_parse () {\n+\td=\n+\twhile :\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t-C) d=\"$2\"; shift; shift ;;\n+\t\t-*) error \"test_rev_parse: unrecognized option '$1'\" ;;\n+\t\t*) break ;;\n+\t\tesac\n+\tdone\n+\n \tname=$1\n \tshift\n \n@@ -18,7 +28,7 @@ test_rev_parse () {\n \t\texpect=\"$1\"\n \t\ttest_expect_success \"$name: $o\" '\n \t\t\techo \"$expect\" >expect &&\n-\t\t\tgit rev-parse $o >actual &&\n+\t\t\tgit ${d:+-C} ${d:+\"$d\"} rev-parse $o >actual &&\n \t\t\ttest_cmp expect actual\n \t\t'\n \t\tshift\n@@ -34,15 +44,10 @@ test_expect_success 'setup' '\n \n test_rev_parse toplevel false false true '' .git\n \n-cd .git || exit 1\n-test_rev_parse .git/ false true false '' .\n-cd objects || exit 1\n-test_rev_parse .git/objects/ false true false '' \"$ROOT/.git\"\n-cd ../.. || exit 1\n+test_rev_parse -C .git .git/ false true false '' .\n+test_rev_parse -C .git/objects .git/objects/ false true false '' \"$ROOT/.git\"\n \n-cd sub/dir || exit 1\n-test_rev_parse subdirectory false false true sub/dir/ \"$ROOT/.git\"\n-cd ../.. || exit 1\n+test_rev_parse -C sub/dir subdirectory false false true sub/dir/ \"$ROOT/.git\"\n \n git config core.bare true\n test_rev_parse 'core.bare = true' true false false\n@@ -50,30 +55,29 @@ test_rev_parse 'core.bare = true' true false false\n git config --unset core.bare\n test_rev_parse 'core.bare undefined' false false true\n \n-cd work || exit 1\n GIT_DIR=../.git\n-GIT_CONFIG=\"$(pwd)\"/../.git/config\n+GIT_CONFIG=\"$(pwd)/work/../.git/config\"\n export GIT_DIR GIT_CONFIG\n \n git config core.bare false\n-test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''\n+test_rev_parse -C work 'GIT_DIR=../.git, core.bare = false' false false true ''\n \n git config core.bare true\n-test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''\n+test_rev_parse -C work 'GIT_DIR=../.git, core.bare = true' true false false ''\n \n git config --unset core.bare\n-test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''\n+test_rev_parse -C work 'GIT_DIR=../.git, core.bare undefined' false false true ''\n \n GIT_DIR=../repo.git\n-GIT_CONFIG=\"$(pwd)\"/../repo.git/config\n+GIT_CONFIG=\"$(pwd)/work/../repo.git/config\"\n \n git config core.bare false\n-test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''\n+test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = false' false false true ''\n \n git config core.bare true\n-test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''\n+test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = true' true false false ''\n \n git config --unset core.bare\n-test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true ''\n+test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare undefined' false false true ''\n \n test_done\n-- \n2.8.2.748.g927f425\n"},{"id":"286922","messageId":"20160518201545.9113-5-sunshine@sunshineco.com","threadId":"42375","inReplyTo":"20160518201545.9113-1-sunshine@sunshineco.com","subject":"[PATCH v3 4/5] t1500: avoid setting configuration options outside of tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-18T20:15:44Z","receivedAt":"2016-05-18T20:15:44Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Ideally, each test should be responsible for setting up state it needs\nrather than relying upon transient global state. Toward this end, teach\ntest_rev_parse() to accept a \"-b <value>\" option to allow callers to set\n\"core.bare\" explicitly or undefine it. Take advantage of this new option\nto avoid setting \"core.bare\" outside of tests.\n\nUnder the hood, \"-b <value>\" invokes \"test_config -C <dir>\" (or\n\"test_unconfig -C <dir>\"), thus git-config knows explicitly where to\nfind its configuration file. Consequently, the global GIT_CONFIG\nenvironment variable required by the manual git-config invocations\noutside of tests is no longer needed, and is thus dropped.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/t1500-rev-parse.sh | 39 ++++++++++++++++++++-------------------\n 1 file changed, 20 insertions(+), 19 deletions(-)\n\ndiff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh\nindex d73a52b..325d821 100755\n--- a/t/t1500-rev-parse.sh\n+++ b/t/t1500-rev-parse.sh\n@@ -6,10 +6,15 @@ test_description='test git rev-parse'\n # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir\n test_rev_parse () {\n \td=\n+\tbare=\n \twhile :\n \tdo\n \t\tcase \"$1\" in\n \t\t-C) d=\"$2\"; shift; shift ;;\n+\t\t-b) case \"$2\" in\n+\t\t    [tfu]*) bare=\"$2\"; shift; shift ;;\n+\t\t    *) error \"test_rev_parse: bogus core.bare value '$2'\" ;;\n+\t\t    esac ;;\n \t\t-*) error \"test_rev_parse: unrecognized option '$1'\" ;;\n \t\t*) break ;;\n \t\tesac\n@@ -27,6 +32,12 @@ test_rev_parse () {\n \t\ttest $# -eq 0 && break\n \t\texpect=\"$1\"\n \t\ttest_expect_success \"$name: $o\" '\n+\t\t\tcase \"$bare\" in\n+\t\t\tt*) test_config ${d:+-C} ${d:+\"$d\"} core.bare true ;;\n+\t\t\tf*) test_config ${d:+-C} ${d:+\"$d\"} core.bare false ;;\n+\t\t\tu*) test_unconfig ${d:+-C} ${d:+\"$d\"} core.bare ;;\n+\t\t\tesac &&\n+\n \t\t\techo \"$expect\" >expect &&\n \t\t\tgit ${d:+-C} ${d:+\"$d\"} rev-parse $o >actual &&\n \t\t\ttest_cmp expect actual\n@@ -49,35 +60,25 @@ test_rev_parse -C .git/objects .git/objects/ false true false '' \"$ROOT/.git\"\n \n test_rev_parse -C sub/dir subdirectory false false true sub/dir/ \"$ROOT/.git\"\n \n-git config core.bare true\n-test_rev_parse 'core.bare = true' true false false\n+test_rev_parse -b t 'core.bare = true' true false false\n \n-git config --unset core.bare\n-test_rev_parse 'core.bare undefined' false false true\n+test_rev_parse -b u 'core.bare undefined' false false true\n \n GIT_DIR=../.git\n-GIT_CONFIG=\"$(pwd)/work/../.git/config\"\n-export GIT_DIR GIT_CONFIG\n+export GIT_DIR\n \n-git config core.bare false\n-test_rev_parse -C work 'GIT_DIR=../.git, core.bare = false' false false true ''\n+test_rev_parse -C work -b f 'GIT_DIR=../.git, core.bare = false' false false true ''\n \n-git config core.bare true\n-test_rev_parse -C work 'GIT_DIR=../.git, core.bare = true' true false false ''\n+test_rev_parse -C work -b t 'GIT_DIR=../.git, core.bare = true' true false false ''\n \n-git config --unset core.bare\n-test_rev_parse -C work 'GIT_DIR=../.git, core.bare undefined' false false true ''\n+test_rev_parse -C work -b u 'GIT_DIR=../.git, core.bare undefined' false false true ''\n \n GIT_DIR=../repo.git\n-GIT_CONFIG=\"$(pwd)/work/../repo.git/config\"\n \n-git config core.bare false\n-test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = false' false false true ''\n+test_rev_parse -C work -b f 'GIT_DIR=../repo.git, core.bare = false' false false true ''\n \n-git config core.bare true\n-test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = true' true false false ''\n+test_rev_parse -C work -b t 'GIT_DIR=../repo.git, core.bare = true' true false false ''\n \n-git config --unset core.bare\n-test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare undefined' false false true ''\n+test_rev_parse -C work -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''\n \n test_done\n-- \n2.8.2.748.g927f425\n"},{"id":"286923","messageId":"20160518201545.9113-6-sunshine@sunshineco.com","threadId":"42375","inReplyTo":"20160518201545.9113-1-sunshine@sunshineco.com","subject":"[PATCH v3 5/5] t1500: avoid setting environment variables outside of tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-18T20:15:45Z","receivedAt":"2016-05-18T20:15:45Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Ideally, each test should be responsible for setting up state it needs\nrather than relying upon transient global state. Toward this end, teach\ntest_rev_parse() to accept a \"-g <dir>\" option to allow callers to\nspecify the value of the GIT_DIR environment variable explicitly. Take\nadvantage of this new option to avoid polluting the global scope with\nGIT_DIR assignments.\n\nImplementation note: Typically, tests avoid polluting the global state\nby wrapping transient environment variable assignments within a\nsubshell, however, this technique doesn't work here since test_config()\nand test_unconfig() need to know GIT_DIR, as well, but neither function\ncan be used within a subshell. Consequently, GIT_DIR is instead cleared\nmanually via test_when_finished().\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n t/t1500-rev-parse.sh | 24 +++++++++++++++---------\n 1 file changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh\nindex 325d821..038e24c 100755\n--- a/t/t1500-rev-parse.sh\n+++ b/t/t1500-rev-parse.sh\n@@ -7,6 +7,7 @@ test_description='test git rev-parse'\n test_rev_parse () {\n \td=\n \tbare=\n+\tgitdir=\n \twhile :\n \tdo\n \t\tcase \"$1\" in\n@@ -15,6 +16,7 @@ test_rev_parse () {\n \t\t    [tfu]*) bare=\"$2\"; shift; shift ;;\n \t\t    *) error \"test_rev_parse: bogus core.bare value '$2'\" ;;\n \t\t    esac ;;\n+\t\t-g) gitdir=\"$2\"; shift; shift ;;\n \t\t-*) error \"test_rev_parse: unrecognized option '$1'\" ;;\n \t\t*) break ;;\n \t\tesac\n@@ -32,6 +34,13 @@ test_rev_parse () {\n \t\ttest $# -eq 0 && break\n \t\texpect=\"$1\"\n \t\ttest_expect_success \"$name: $o\" '\n+\t\t\tif test -n \"$gitdir\"\n+\t\t\tthen\n+\t\t\t\ttest_when_finished \"unset GIT_DIR\" &&\n+\t\t\t\tGIT_DIR=\"$gitdir\" &&\n+\t\t\t\texport GIT_DIR\n+\t\t\tfi &&\n+\n \t\t\tcase \"$bare\" in\n \t\t\tt*) test_config ${d:+-C} ${d:+\"$d\"} core.bare true ;;\n \t\t\tf*) test_config ${d:+-C} ${d:+\"$d\"} core.bare false ;;\n@@ -64,21 +73,18 @@ test_rev_parse -b t 'core.bare = true' true false false\n \n test_rev_parse -b u 'core.bare undefined' false false true\n \n-GIT_DIR=../.git\n-export GIT_DIR\n \n-test_rev_parse -C work -b f 'GIT_DIR=../.git, core.bare = false' false false true ''\n+test_rev_parse -C work -g ../.git -b f 'GIT_DIR=../.git, core.bare = false' false false true ''\n \n-test_rev_parse -C work -b t 'GIT_DIR=../.git, core.bare = true' true false false ''\n+test_rev_parse -C work -g ../.git -b t 'GIT_DIR=../.git, core.bare = true' true false false ''\n \n-test_rev_parse -C work -b u 'GIT_DIR=../.git, core.bare undefined' false false true ''\n+test_rev_parse -C work -g ../.git -b u 'GIT_DIR=../.git, core.bare undefined' false false true ''\n \n-GIT_DIR=../repo.git\n \n-test_rev_parse -C work -b f 'GIT_DIR=../repo.git, core.bare = false' false false true ''\n+test_rev_parse -C work -g ../repo.git -b f 'GIT_DIR=../repo.git, core.bare = false' false false true ''\n \n-test_rev_parse -C work -b t 'GIT_DIR=../repo.git, core.bare = true' true false false ''\n+test_rev_parse -C work -g ../repo.git -b t 'GIT_DIR=../repo.git, core.bare = true' true false false ''\n \n-test_rev_parse -C work -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''\n+test_rev_parse -C work -g ../repo.git -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''\n \n test_done\n-- \n2.8.2.748.g927f425\n"}]}