1

Objective

Create an annotated tag with an empty message, as would be created with the following command.

$ git tag --annotate epic-tag --message=""

Attempts

  1. Create it with M-x magit-tag<RET> -a t tag-name<RET> <RET> C-c C-c. This does not work, because git interprets no message specified interactively as don't create tag, resulting in the following in the magit-process buffer.
...
git … tag --annotate tag-name master
hint: Waiting for your editor to close the file...
Waiting for Emacs...
fatal: no tag message?
  1. Add argument --message= to magit-tag. I added a --message= argument to magit-tag(see branch or patch), but when I try using my argument with an empty value it interprets it as cancelling the argument. Using '' or "" as a value literally uses '' or "" for the tag message.

  2. Add a "virtual argument" -e that adds --message='' to the command. That also used '' as a literal tag message. See branch or patch.

Anti-solutions

  • Use lightweight tags. The tags must be annotated because they are meant for release*.

* Annotated tags are meant for release while lightweight tags are meant for private or temporary object labels. - GIT-TAG(1)

1

Solution

I updated my transient argument to accept empty values and now it works. commit patch

Update

Instead of customising Magit itself, one can add the argument to your personal configuration. Add the following code to your configuration to add an argument -m, to magit-tag, that accepts a optionally-empty message string.

(transient-define-argument magit-tag:--message ()
  :description "Use message"
  :class 'transient-option
  :shortarg "-m"
  :argument "--message="
  ;; Empty (annotated)tag messages must be permitted because it is
  ;; impossible to create them interactively.
  :allow-empty t)
(transient-append-suffix
  'magit-tag
  "-u"
  '(magit-tag:--message)))
| improve this answer | |
  • You should open an issue/pull request with magit and see if they will accept your patch. – NickD Nov 12 at 14:32
  • 1
    Hey, sorry for deleting my comment. I ended up not writing tests cases because looking at Magit's test suite I was unsure if it was appropriate to test it. Either way the pr is at github.com/magit/magit/pull/4247. – fossegrim Nov 12 at 15:54
  • The pr was rejected, but kyleam suggested me a way to add the argument from a personal configuration instead of from the magit source. I will ~write another~ update my answer. – fossegrim Nov 20 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.