Re: [PATCH 1/2] t3312-notes-empty: Test that 'git notes' removes empty notes by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johan Herland <johan@xxxxxxxxxxx> writes:

> Add test cases documenting the current behavior when trying to
> add/append/edit empty notes. This is in preparation for adding
> --allow-empty; to allow empty notes to be stored.
>
> Signed-off-by: Johan Herland <johan@xxxxxxxxxxx>
> ---
>  t/t3312-notes-empty.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
>  create mode 100755 t/t3312-notes-empty.sh

By definition, an empty note is empty ;-) and devoid of useful
information other than a single bit, its existence.  I would
understand a handful of tests that check "oh by the way, we should
also handle empty ones sensibly", but are you sure that a _new_
separate test script, not addition to existing test script, is worth
to check _only_ empty notes?

> diff --git a/t/t3312-notes-empty.sh b/t/t3312-notes-empty.sh
> new file mode 100755
> index 0000000..2806d27
> --- /dev/null
> +++ b/t/t3312-notes-empty.sh
> @@ -0,0 +1,58 @@
> +#!/bin/sh
> +
> +test_description='Test adding/editing of empty notes'
> +. ./test-lib.sh
> +
> +cat >fake_editor.sh <<\EOF
> +#!/bin/sh
> +echo "$MSG" >"$1"
> +echo "$MSG" >& 2
> +EOF
> +chmod a+x fake_editor.sh
> +GIT_EDITOR=./fake_editor.sh
> +export GIT_EDITOR
> +
> +test_expect_success 'setup' '
> +	test_commit one &&
> +	empty_blob=$(git hash-object -w /dev/null)
> +'
> +
> +cleanup_notes() {
> +	git update-ref -d refs/notes/commits
> +}
> +
> +cat >expect_missing <<\EOF
> +commit d79ce1670bdcb76e6d1da2ae095e890ccb326ae9
> +Author: A U Thor <author@xxxxxxxxxxx>
> +Date:   Thu Apr 7 15:13:13 2005 -0700
> +
> +    one
> +EOF
> +
> +verify_missing() {
> +	git log -1 > actual &&
> +	test_cmp expect_missing actual &&
> +	! git notes list HEAD
> +}
> +
> +for cmd in \
> +	'add' \
> +	'add -F /dev/null' \
> +	'add -m ""' \
> +	'add -c "$empty_blob"' \
> +	'add -C "$empty_blob"' \
> +	'append' \
> +	'append -F /dev/null' \
> +	'append -m ""' \
> +	'append -c "$empty_blob"' \
> +	'append -C "$empty_blob"' \
> +	'edit'
> +do
> +	test_expect_success "'git notes $cmd' removes empty note" "
> +		cleanup_notes &&
> +		MSG= git notes $cmd &&
> +		verify_missing
> +	"
> +done
> +
> +test_done
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]