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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got: fix incorrect argc check when diffing blobs
To:
Omar Polo <op@omarpolo.com>
Cc:
Mark Jamsek <mark@jamsek.com>, Game of Trees <gameoftrees@openbsd.org>
Date:
Tue, 30 Aug 2022 13:07:26 +0200

Download raw body.

Thread
On Tue, Aug 30, 2022 at 12:10:53PM +0200, Omar Polo wrote:
> yeah, we can do better.  Here's another attemp less hacky with
> get_blob_id

ok, thanks!

> diff /home/op/w/got
> commit - e4556f5ad27817d84c98b820f3e952b57c4e926c
> path + /home/op/w/got
> blob - 136f659b08eaf6408f6c79e05f6440fe7c754523
> file + regress/cmdline/diff.sh
> --- regress/cmdline/diff.sh
> +++ regress/cmdline/diff.sh
> @@ -19,6 +19,7 @@
>  test_diff_basic() {
>  	local testroot=`test_init diff_basic`
>  	local head_rev=`git_show_head $testroot/repo`
> +	local alpha_blobid=`get_blob_id $testroot/repo "" alpha`
>  
>  	got checkout $testroot/repo $testroot/wt > /dev/null
>  	ret=$?
> @@ -385,6 +386,37 @@ test_diff_basic() {
>  		diff -u $testroot/stderr.expected $testroot/stderr
>  		return 1
>  	fi
> +
> +	# diff two blob ids
> +	(cd $testroot/wt && got commit -m 'edit' alpha >/dev/null)
> +	local alpha_new_blobid=`get_blob_id $testroot/repo "" alpha`
> +	(cd $testroot/wt && got diff $alpha_blobid $alpha_new_blobid) > $testroot/diff
> +	ret=$?
> +	if [ $ret -ne 0 ]; then
> +		echo "diff failed unexpectedly" >&2
> +		test_done "$testroot" "$ret"
> +		return 1
> +	fi
> +
> +	cat <<EOF >$testroot/diff.expected
> +blob - $alpha_blobid
> +blob + $alpha_new_blobid
> +--- $alpha_blobid
> ++++ $alpha_new_blobid
> +@@ -1 +1 @@
> +-alpha
> ++modified alpha
> +EOF
> +
> +	cmp -s $testroot/diff.expected $testroot/diff
> +	ret=$?
> +	if [ $ret -ne 0 ]; then
> +		echo
> +		diff -u $testroot/diff.expected $testroot/diff
> +		test_done "$testroot" "$ret"
> +		return 1
> +	fi
> +
>  	test_done "$testroot" "$ret"
>  }
>  
>