t5516-fetch-push: fix 'push with dry-run' test
commitcfb482b6c33508c3a14b721b1e48a881fcbe7146
authorSZEDER Gábor <szeder.dev@gmail.com>
Thu, 10 May 2018 14:01:53 +0000 (10 16:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 11 May 2018 03:32:51 +0000 (11 12:32 +0900)
tree0d1e85ab9fdd0b1a47ccdfd09bfba1752b071548
parent468165c1d8a442994a825f3684528361727cd8c0
t5516-fetch-push: fix 'push with dry-run' test

In a while-at-it cleanup replacing a 'cd dir && <...> && cd ..' with a
subshell, commit 28391a80a9 (receive-pack: allow deletion of corrupt
refs, 2007-11-29) also moved the assignment of the $old_commit
variable to that subshell.  This variable, however, is used outside of
that subshell as a parameter of check_push_result(), to check that a
ref still points to the commit where it is supposed to.  With the
variable remaining unset outside the subshell check_push_result()
doesn't perform that check at all.

Use 'git -C <dir> cmd...', so we don't need to change directory, and
thus don't need the subshell either when setting $old_commit.

Furthermore, change check_push_result() to require at least three
parameters (the repo, the oid, and at least one ref), so it will catch
similar issues earlier should they ever arise.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5516-fetch-push.sh