Re: [PATCH v2 0/3] tag: keep the message file in case ref transaction fails
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 15, 2023, 21:50 UTC
- Message-ID
- <xmqq7ct98dsn.fsf@gitster.g>
- In-Reply-To
- <cover.1684181855.git.code@khaugsbakk.name>
Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
> + GIT_EDITOR=./fakeeditor git tag -a foo && > -+ ! test -e .git/TAG_EDITMSG > ++ ! test_path_exists .git/TAG_EDITMSG
This is not quite right. test_path_exists is loud when its expectation that the path _exists_ is not met, i.e.
test_path_exists () {
test "$#" -ne 1 && BUG "1 param"
if ! test -e "$1"
then
echo "Path $1 doesn't exist"
false
fi
}But this test expects that .git/TAG_EDITMSG to be missing. When the test is run with "-v" to make the output from this 'echo' visible, we will keep getting the complaint when the test is happy, which is not quite what we want.
What you want to use is test_path_is_missing, without "!".
Show 10 quoted lines
> ## Notes (series) ##
> - I tried to maintain the proper formatting by using `clang-format` via Emacs on
> - the affected lines.
> + I duplicated this message (this isn’t obvious in the diff):
> +
> + fprintf(stderr,
> + _("The tag message has been left in %s\n"),
> + path);
> +
> + Should this be factored into a static function instead?When the third copy is made, we would definitely insist avoiding copies, but until then, I am indifferent. Others may have different opinions, though.