t/t5528-push-default: generalize test_push_*

The setup creates two bare repositories: repo1 and repo2, but test_push_commit() hard-codes checking in repo1 for the actual output. Generalize it and its caller, test_push_success(), to optionally accept a third argument to specify the name of the repository to check for actual output. We will use this in the next patch. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed Jun 19, 2013 at 16:41 UTC 396243fa479cd27bef1ced2ea5a9e4cf20f85a4b
1 file changed +4 -2
t/t5528-push-default.sh
+4 -2
@@ -15,17 +15,19 @@ test_expect_success 'setup bare remotes' '
15
16 # $1 = local revision
17 # $2 = remote revision (tested to be equal to the local one)
18 +# $3 = [optional] repo to check for actual output (repo1 by default)
19 check_pushed_commit () {
20 git log -1 --format='%h %s' "$1" >expect &&
20 - git --git-dir=repo1 log -1 --format='%h %s' "$2" >actual &&
21 + git --git-dir="${3:-repo1}" log -1 --format='%h %s' "$2" >actual &&
22 test_cmp expect actual
23 }
24
25 # $1 = push.default value
26 # $2 = expected target branch for the push
27 +# $3 = [optional] repo to check for actual output (repo1 by default)
28 test_push_success () {
29 git -c push.default="$1" push &&
28 - check_pushed_commit HEAD "$2"
30 + check_pushed_commit HEAD "$2" "$3"
31 }
32
33 # $1 = push.default value