Skip to content

Commit 64568c7

Browse files
avargitster
authored andcommitted
describe tests: support -C in "check_describe"
Change a subshell added in a preceding commit to instead use a new "-C" option to "check_describe". The idiom for this is copied as-is from the "test_commit" function in test-lib-functions.sh Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 33b4ae1 commit 64568c7

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

t/t6120-describe.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,26 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1717
. ./test-lib.sh
1818

1919
check_describe () {
20+
indir= &&
21+
while test $# != 0
22+
do
23+
case "$1" in
24+
-C)
25+
indir="$2"
26+
shift
27+
;;
28+
*)
29+
break
30+
;;
31+
esac
32+
shift
33+
done &&
34+
indir=${indir:+"$indir"/} &&
2035
expect="$1"
2136
shift
2237
describe_opts="$@"
2338
test_expect_success "describe $describe_opts" '
24-
git describe $describe_opts >raw &&
39+
git ${indir:+ -C "$indir"} describe $describe_opts >raw &&
2540
sed -e "s/-g[0-9a-f]*\$/-gHASH/" <raw >actual &&
2641
echo "$expect" >expect &&
2742
test_cmp expect actual
@@ -486,10 +501,7 @@ test_expect_success 'setup: describe commits with disjoint bases' '
486501
)
487502
'
488503

489-
(
490-
cd disjoint1 &&
491-
check_describe "A-3-gHASH" HEAD
492-
)
504+
check_describe -C disjoint1 "A-3-gHASH" HEAD
493505

494506
# B
495507
# o---o---o------------.
@@ -515,9 +527,6 @@ test_expect_success 'setup: describe commits with disjoint bases 2' '
515527
)
516528
'
517529

518-
(
519-
cd disjoint2 &&
520-
check_describe "B-3-gHASH" HEAD
521-
)
530+
check_describe -C disjoint2 "B-3-gHASH" HEAD
522531

523532
test_done

0 commit comments

Comments
 (0)