diff mbox series

[1/3] t/t7004-tag: add regression test for existing behavior

Message ID 87b709d856d8f788a2a50a2804ac508d5775f324.1684067644.git.code@khaugsbakk.name (mailing list archive)
State Superseded
Headers show
Series tag: keep the message file in case ref transaction fails | expand

Commit Message

Kristoffer Haugsbakk May 14, 2023, 1:17 p.m. UTC
The standard tag message file is unlinked if the tag is created.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---

Notes (series):
    `test_when_finished` because this test interferes with the next one
    without it.

 t/t7004-tag.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Junio C Hamano May 15, 2023, 6:59 a.m. UTC | #1
Kristoffer Haugsbakk <code@khaugsbakk.name> writes:

> The standard tag message file is unlinked if the tag is created.
>
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
>
> Notes (series):
>     `test_when_finished` because this test interferes with the next one
>     without it.

Use of when-finished to remove a tag makes sense.

Unlike COMMIT_EDITMSG that is documented in "git commit --help", we
do not promise the users that the temporary file that is used for
preparing a tag message is "$GIT_DIR/TAG_EDITMSG" in any of our
documentation.  That needs to be done at the same time, or before,
this new test makes such a promise.

>  t/t7004-tag.sh | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> index 9aa1660651..550b5b1cce 100755
> --- a/t/t7004-tag.sh
> +++ b/t/t7004-tag.sh
> @@ -2127,4 +2127,13 @@ test_expect_success 'Does --[no-]contains stop at commits? Yes!' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'If tag is created then tag message file is unlinked' '
> +	test_when_finished "git tag -d foo" &&
> +	write_script fakeeditor <<-\EOF &&
> +	echo Message >.git/TAG_EDITMSG
> +	EOF
> +	GIT_EDITOR=./fakeeditor git tag -a foo &&
> +	! test -e .git/TAG_EDITMSG

I'd recommend using "test_path_is_missing" instead for better
test-debugging experience.

Thanks.
diff mbox series

Patch

diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 9aa1660651..550b5b1cce 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -2127,4 +2127,13 @@  test_expect_success 'Does --[no-]contains stop at commits? Yes!' '
 	test_cmp expected actual
 '
 
+test_expect_success 'If tag is created then tag message file is unlinked' '
+	test_when_finished "git tag -d foo" &&
+	write_script fakeeditor <<-\EOF &&
+	echo Message >.git/TAG_EDITMSG
+	EOF
+	GIT_EDITOR=./fakeeditor git tag -a foo &&
+	! test -e .git/TAG_EDITMSG
+'
+
 test_done