* [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test
@ 2018-05-10 14:01 SZEDER Gábor
2018-05-10 14:01 ` [PATCH 2/2] t5516-fetch-push: fix broken &&-chain SZEDER Gábor
2018-05-11 3:32 ` [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test Junio C Hamano
0 siblings, 2 replies; 3+ messages in thread
From: SZEDER Gábor @ 2018-05-10 14:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, SZEDER Gábor
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>
---
t/t5516-fetch-push.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 82239138d5..832b79ad40 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -94,6 +94,9 @@ mk_child() {
}
check_push_result () {
+ test $# -ge 3 ||
+ error "bug in the test script: check_push_result requires at least 3 parameters"
+
repo_name="$1"
shift
@@ -553,10 +556,7 @@ test_expect_success 'branch.*.pushremote config order is irrelevant' '
test_expect_success 'push with dry-run' '
mk_test testrepo heads/master &&
- (
- cd testrepo &&
- old_commit=$(git show-ref -s --verify refs/heads/master)
- ) &&
+ old_commit=$(git -C testrepo show-ref -s --verify refs/heads/master) &&
git push --dry-run testrepo : &&
check_push_result testrepo $old_commit heads/master
'
--
2.17.0.756.gcf614c5aff
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] t5516-fetch-push: fix broken &&-chain
2018-05-10 14:01 [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test SZEDER Gábor
@ 2018-05-10 14:01 ` SZEDER Gábor
2018-05-11 3:32 ` [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: SZEDER Gábor @ 2018-05-10 14:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, SZEDER Gábor
b2dc968e60 (t5516: refactor oddball tests, 2008-11-07) accidentaly
broke the &&-chain in the test 'push does not update local refs on
failure', but since it was in a subshell, chain-lint couldn't notice
it.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
t/t5516-fetch-push.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 832b79ad40..3e8940eee5 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -612,7 +612,7 @@ test_expect_success 'push does not update local refs on failure' '
chmod +x testrepo/.git/hooks/pre-receive &&
(
cd child &&
- git pull .. master
+ git pull .. master &&
test_must_fail git push &&
test $(git rev-parse master) != \
$(git rev-parse remotes/origin/master)
--
2.17.0.756.gcf614c5aff
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test
2018-05-10 14:01 [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test SZEDER Gábor
2018-05-10 14:01 ` [PATCH 2/2] t5516-fetch-push: fix broken &&-chain SZEDER Gábor
@ 2018-05-11 3:32 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2018-05-11 3:32 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: git
SZEDER Gábor <szeder.dev@gmail.com> writes:
> 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.
Sigh/Blush. Thanks for finding an old screw-up.
>
> 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>
> ---
> t/t5516-fetch-push.sh | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
> index 82239138d5..832b79ad40 100755
> --- a/t/t5516-fetch-push.sh
> +++ b/t/t5516-fetch-push.sh
> @@ -94,6 +94,9 @@ mk_child() {
> }
>
> check_push_result () {
> + test $# -ge 3 ||
> + error "bug in the test script: check_push_result requires at least 3 parameters"
> +
> repo_name="$1"
> shift
>
> @@ -553,10 +556,7 @@ test_expect_success 'branch.*.pushremote config order is irrelevant' '
> test_expect_success 'push with dry-run' '
>
> mk_test testrepo heads/master &&
> - (
> - cd testrepo &&
> - old_commit=$(git show-ref -s --verify refs/heads/master)
> - ) &&
> + old_commit=$(git -C testrepo show-ref -s --verify refs/heads/master) &&
> git push --dry-run testrepo : &&
> check_push_result testrepo $old_commit heads/master
> '
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-11 3:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 14:01 [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test SZEDER Gábor
2018-05-10 14:01 ` [PATCH 2/2] t5516-fetch-push: fix broken &&-chain SZEDER Gábor
2018-05-11 3:32 ` [PATCH 1/2] t5516-fetch-push: fix 'push with dry-run' test Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).