This is a re-roll of [1] which modernizes t1500 by updating tests to set up their own needed state rather than relying upon manipulation of global state. Changes since v2[1]: Avoid POSIX ${dir:+-C "$dir"} since some older broken shells incorrectly expand this to a single argument ("-C <dir>") rather than the expected two (-C and "<dir>"). Thanks to Peff and SZEDER for providing links to previous reports of this problem[2][3]. Include the leading dashes in option names iterated over by the for-loop in test_rev_parse() to potentially make it easier for some future change to specify multiple options at once to git-rev-parse (SZEDER's example[4] was "git rev-parse --absolute-path --git-dir"). A v2 to v3 interdiff is included below. [1]: http://thread.gmane.org/gmane.comp.version-control.git/294902 [2]: http://thread.gmane.org/gmane.comp.version-control.git/294902/focus=294916 [3]: http://thread.gmane.org/gmane.comp.version-control.git/294902/focus=294923 [4]: http://thread.gmane.org/gmane.comp.version-control.git/294902/focus=294971 Eric Sunshine (5): t1500: be considerate to future potential tests t1500: test_rev_parse: facilitate future test enhancements t1500: avoid changing working directory outside of tests t1500: avoid setting configuration options outside of tests t1500: avoid setting environment variables outside of tests t/t1500-rev-parse.sh | 123 ++++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 60 deletions(-) --- >8 --- diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 39af565..038e24c 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -5,13 +5,13 @@ test_description='test git rev-parse' # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir test_rev_parse () { - dir= + d= bare= gitdir= while : do case "$1" in - -C) dir="$2"; shift; shift ;; + -C) d="$2"; shift; shift ;; -b) case "$2" in [tfu]*) bare="$2"; shift; shift ;; *) error "test_rev_parse: bogus core.bare value '$2'" ;; @@ -25,11 +25,11 @@ test_rev_parse () { name=$1 shift - for o in is-bare-repository \ - is-inside-git-dir \ - is-inside-work-tree \ - show-prefix \ - git-dir + for o in --is-bare-repository \ + --is-inside-git-dir \ + --is-inside-work-tree \ + --show-prefix \ + --git-dir do test $# -eq 0 && break expect="$1" @@ -42,13 +42,13 @@ test_rev_parse () { fi && case "$bare" in - t*) test_config ${dir:+-C "$dir"} core.bare true ;; - f*) test_config ${dir:+-C "$dir"} core.bare false ;; - u*) test_unconfig ${dir:+-C "$dir"} core.bare ;; + t*) test_config ${d:+-C} ${d:+"$d"} core.bare true ;; + f*) test_config ${d:+-C} ${d:+"$d"} core.bare false ;; + u*) test_unconfig ${d:+-C} ${d:+"$d"} core.bare ;; esac && echo "$expect" >expect && - git ${dir:+-C "$dir"} rev-parse --$o >actual && + git ${d:+-C} ${d:+"$d"} rev-parse $o >actual && test_cmp expect actual ' shift --- >8 --- -- 2.8.2.748.g927f425 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html