summaryrefslogtreecommitdiff
path: root/t/t5411/common-functions.sh
diff options
context:
space:
mode:
authorJiang Xin <zhiyou.jx@alibaba-inc.com>2021-01-21 02:53:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-22 21:09:06 (GMT)
commit822ee894f621674610a36cc9a84a9ffbbb8fb6bb (patch)
tree70c3efa9e94bacf13970a1ae8681b4a24e155615 /t/t5411/common-functions.sh
parent8388a64cd1186674cffbb032d940c1c35be1f627 (diff)
downloadgit-822ee894f621674610a36cc9a84a9ffbbb8fb6bb.zip
git-822ee894f621674610a36cc9a84a9ffbbb8fb6bb.tar.gz
git-822ee894f621674610a36cc9a84a9ffbbb8fb6bb.tar.bz2
t5411: refactor check of refs using test_cmp_refs
Add new helper 'test_cmp_refs' to check references in a repository. Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5411/common-functions.sh')
-rw-r--r--t/t5411/common-functions.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh
index 344d13f..4835dd5 100644
--- a/t/t5411/common-functions.sh
+++ b/t/t5411/common-functions.sh
@@ -59,3 +59,18 @@ filter_out_user_friendly_and_stable_output () {
make_user_friendly_and_stable_output |
sed -n ${1+"$@"}
}
+
+test_cmp_refs () {
+ indir=
+ if test "$1" = "-C"
+ then
+ shift
+ indir="$1"
+ shift
+ fi
+ indir=${indir:+"$indir"/}
+ cat >show-ref.expect &&
+ git ${indir:+ -C "$indir"} show-ref >show-ref.pristine &&
+ make_user_friendly_and_stable_output <show-ref.pristine >show-ref.filtered &&
+ test_cmp show-ref.expect show-ref.filtered
+}