diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2016-05-18 16:15:43 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-05-18 14:14:31 -0700 |
commit | 1e043cff7815786b3d1a4c07bac63b3d8e1e30ef (patch) | |
tree | 9449561f4a8013fa80c3fcd04fb667a473ab4738 /t/t1403-show-ref.sh | |
parent | t1500: test_rev_parse: facilitate future test enhancements (diff) | |
download | tgif-1e043cff7815786b3d1a4c07bac63b3d8e1e30ef.tar.xz |
t1500: avoid changing working directory outside of tests
Ideally, each test should be responsible for setting up state it needs
rather than relying upon transient global state. Toward this end, teach
test_rev_parse() to accept a "-C <dir>" option to allow callers to
instruct it explicitly in which directory its tests should be run. Take
advantage of this new option to avoid changing the working directory
outside of tests.
Implementation note: test_rev_parse() passes "-C <dir>" along to
git-rev-parse with <dir> properly quoted. The natural and POSIX way to
do so is via ${dir:+-C "$dir"}, however, with some older broken shells,
this expression evaluates incorrectly to a single argument ("-C <dir>")
rather than the expected two (-C and "<dir>"). Work around this problem
with the slightly ungainly expression: ${dir:+-C} ${dir:+"$dir"}
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1403-show-ref.sh')
0 files changed, 0 insertions, 0 deletions