Re: [PATCH] transport-helper: enforce atomic in push_refs_with_push
On Tue, Jul 02, 2019 at 02:37:42PM -0700, Junio C Hamano wrote:
Show 21 quoted lines
> >
> > +test_expect_success 'push --atomic also prevents branch creation' '
> > + # Make up/master
> > + d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-branches.git &&
> > + git init --bare "$d" &&
> > + git --git-dir="$d" config http.receivepack true &&
> > + up="$HTTPD_URL"/smart/atomic-branches.git &&
> > + test_commit atomic1 &&
> > + test_commit atomic2 &&
> > + git push "$up" master &&
> > + # Make master incompatible with up/master
> > + git reset --hard HEAD^ &&
> > + # Add a new branch
> > + git branch atomic &&
> > + # --atomic should roll back creation of up/atomic
> > + test_must_fail git push --atomic "$up" master atomic &&
> > + git ls-remote "$up" >up-remotes &&
> > + test_must_fail grep atomic up-remotes
>
> Don't use test_must_fail on non-git things. We are not in the
> business of catching segfaulting system programs.
Done:
! grep atomic up-remotes
Show 27 quoted lines
>
> > +'
> > +
> > +test_expect_success 'push --atomic shows all failed refs' '
> > + # Make up/master, up/allrefs
> > + d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-failed-refs.git &&
> > + git init --bare "$d" &&
> > + git --git-dir="$d" config http.receivepack true &&
> > + up="$HTTPD_URL"/smart/atomic-failed-refs.git &&
> > + test_commit allrefs1 &&
> > + test_commit allrefs2 &&
> > + git branch allrefs &&
> > + git push "$up" master allrefs &&
> > + # Make master and allrefs incompatible with up/master, up/allrefs
> > + git checkout allrefs &&
> > + git reset --hard HEAD^ &&
> > + git checkout master &&
> > + git reset --hard HEAD^ &&
> > + # --atomic should complain about both master and allrefs
> > + test_must_fail git push --atomic "$up" master allrefs >&output &&
>
> Don't rely on ">&output", which is an unnecessary bash-ism here. It
> breaks test run under shells like dash.
>
> >output 2>&1
>
> should be OK.
Show 21 quoted lines
>
> > + grep master output &&
> > + grep allrefs output
> > +'
> > +
> > +test_expect_success 'push --atomic indicates collateral failures' '
> > + # Make up/master, up/collateral
> > + d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-collateral.git &&
> > + git init --bare "$d" &&
> > + git --git-dir="$d" config http.receivepack true &&
> > + up="$HTTPD_URL"/smart/atomic-collateral.git &&
> > + test_commit collateral1 &&
> > + test_commit collateral2 &&
> > + git branch collateral &&
> > + git push "$up" master collateral &&
> > + # Make master incompatible with up/master
> > + git reset --hard HEAD^ &&
> > + # --atomic should mention collateral was OK but failed anyway
> > + test_must_fail git push --atomic "$up" master collateral >&output &&
>
> Ditto.