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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Apr 12, 2021 at 13:21 UTC
64568c717159b31b5a37d2c1bb284c71e6cd011f
1 file changed
+18
-9
t/t6120-describe.sh
+18
-9
@@ -17,11 +17,26 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
17
. ./test-lib.sh
18
19
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"/} &&
35
expect="$1"
36
shift
37
describe_opts="$@"
38
test_expect_success "describe $describe_opts" '
24
- git describe $describe_opts >raw &&
39
+ git ${indir:+ -C "$indir"} describe $describe_opts >raw &&
40
sed -e "s/-g[0-9a-f]*\$/-gHASH/" <raw >actual &&
41
echo "$expect" >expect &&
42
test_cmp expect actual
@@ -486,10 +501,7 @@ test_expect_success 'setup: describe commits with disjoint bases' '
501
)
502
'
503
489
-(
490
- cd disjoint1 &&
491
- check_describe "A-3-gHASH" HEAD
492
-)
504
+check_describe -C disjoint1 "A-3-gHASH" HEAD
505
506
# B
507
# o---o---o------------.
@@ -515,9 +527,6 @@ test_expect_success 'setup: describe commits with disjoint bases 2' '
527
)
528
'
529
518
-(
519
- cd disjoint2 &&
520
- check_describe "B-3-gHASH" HEAD
521
-)
530
+check_describe -C disjoint2 "B-3-gHASH" HEAD
531
532
test_done