"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: gotd: fix cosmetic git push problem
To:
gameoftrees@openbsd.org
Date:
Wed, 7 Jun 2023 15:02:09 +1000

Download raw body.

Thread
On 23-06-06 03:35PM, Stefan Sperling wrote:
> Make gotd work around an error shown by 'git push' with no changes to send.
>  
> git push would show output like:
>  = [up to date]      main -> main
>  error: failed to push some refs to 'ssh://example.com/git/repo.git
>  
> This happened because "unexpected end of file" and "unexpected flush packet"
> errors were reported to the client via gotsh.

Nice find! Minor typo/copypasta mistake in the regress change annotated
below, otherwise ok

> diff cf31b4749a965b44fa03a3c98bdfc8b60f2c987d 68f4e4ff48e662914972bd5d822eccd8aa161a03
> commit - cf31b4749a965b44fa03a3c98bdfc8b60f2c987d
> commit + 68f4e4ff48e662914972bd5d822eccd8aa161a03
> blob - 8f00f2699c2d87d84a815df4188c27ed9fcc45c0
> blob + e4c9601581a5f7e5f5944692c0f36c0130bacfdd
> --- gotd/session.c
> +++ gotd/session.c
> @@ -1046,6 +1046,17 @@ session_dispatch_client(int fd, short events, void *ar
>  		if (err) {
>  			if (err->code == GOT_ERR_PRIVSEP_READ)
>  				err = NULL;
> +			else if (err->code == GOT_ERR_EOF &&
> +			    client->state == GOTD_STATE_EXPECT_CAPABILITIES) {
> +				/*
> +				 * The client has closed its socket before
> +				 * sending its capability announcement.
> +				 * This can happen when Git clients have
> +				 * no ref-updates to send.
> +				 */
> +				disconnect_on_error(client, err);
> +				return;
> +			}
>  			break;
>  		}
>  
> blob - 3d1c9a901f008fc32a17f1ab6a9abc5b444cf986
> blob + b811009e08d9088194ccc086a17fcecac0da7fde
> --- lib/serve.c
> +++ lib/serve.c
> @@ -1270,7 +1270,10 @@ serve_write(int infd, int outfd, int gotd_sock, const 
>  		if (err)
>  			goto done;
>  		if (n == 0) {
> -			if (curstate != STATE_EXPECT_MORE_REF_UPDATES) {
> +			if (curstate == STATE_EXPECT_REF_UPDATE) {
> +				/* The client will not send us anything. */
> +				goto done;
> +			} else if (curstate != STATE_EXPECT_MORE_REF_UPDATES) {
>  				err = got_error_msg(GOT_ERR_BAD_PACKET,
>  				    "unexpected flush packet received");
>  				goto done;
> blob - daff924b47ca360160665215790f700bf0f8bfda
> blob + 83927b35c3c889b14f84b418b4d7235c156e0444
> --- regress/gotd/repo_write.sh
> +++ regress/gotd/repo_write.sh
> @@ -112,6 +112,16 @@ EOF
>  		return 1
>  	fi
>  
> +	# Verify that git push reports no changes to send and no error.
> +	(cd $testroot/repo-clone3 && git push -q > $testroot/stdout \
> +		2> $testroot/stderr)
> +	ret=$?
> +	if [ $ret -ne 0 ]; then
> +		echo "git pull failed unexpectedly" >&2

s/pull/push
		echo "git push failed unexpectedly" >&2

> +		test_done "$testroot" "1"
> +		return 1
> +	fi
> +
>  	# sending to a repository should result in a new pack file
>  	ls -R ${GOTD_TEST_REPO}/objects/pack > $testroot/repo-list.after
>  	diff -u $testroot/repo-list.before $testroot/repo-list.after \
> 

-- 
Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68