Skip to content

Commit 5cf5ade

Browse files
peffgitster
authored andcommitted
t5800: factor out some ref tests
These are a little hard to read, and I'm about to add more just like them. Plus the failure output is nicer if we use test_cmp than a comparison with "test". Signed-off-by: Jeff King <[email protected]> Signed-off-by: Sverre Rabbelier <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2faa152 commit 5cf5ade

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

t/t5800-remote-helpers.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ then
1717
test_set_prereq PYTHON_24
1818
fi
1919

20+
compare_refs() {
21+
git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
22+
git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
23+
test_cmp expect actual
24+
}
25+
2026
test_expect_success PYTHON_24 'setup repository' '
2127
git init --bare server/.git &&
2228
git clone server public &&
@@ -59,8 +65,7 @@ test_expect_success PYTHON_24 'pushing to local repo' '
5965
echo content >>file &&
6066
git commit -a -m three &&
6167
git push) &&
62-
HEAD=$(git --git-dir=localclone/.git rev-parse --verify HEAD) &&
63-
test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
68+
compare_refs localclone HEAD server HEAD
6469
'
6570

6671
test_expect_success PYTHON_24 'synch with changes from localclone' '
@@ -73,8 +78,7 @@ test_expect_success PYTHON_24 'pushing remote local repo' '
7378
echo content >>file &&
7479
git commit -a -m four &&
7580
git push) &&
76-
HEAD=$(git --git-dir=clone/.git rev-parse --verify HEAD) &&
77-
test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
81+
compare_refs clone HEAD server HEAD
7882
'
7983

8084
test_done

0 commit comments

Comments
 (0)