Lucas Oshiro <lucasseikiosh...@gmail.com> writes:

>  struct create_tag_options {
>       unsigned int message_given:1;
>       unsigned int use_editor:1;
> +     unsigned int force_editor:1;
>       unsigned int sign;

> -     if (!opt->message_given || opt->use_editor) {
> +     if (opt->force_editor && !opt->message_given && is_null_oid(prev) &&
> +         !opt->use_editor) {
> +             die(_("no tag message?"));

If we didn't get a message from command line, and there is no
previous tag object to read the message from, there is nowhere but
editor to grab the message to be used, so !use_editor would trigger
an error if force_editor (i.e. the command line explicitly said
either --edit or --no-edit).  Makes sense, but I needed to cheat and
look at cmd_tag() to see how "force" is set to understand what is
going on.  I have to say "force" is not a good name for this field;
is this use similar to what we typically use an additional _given
field?

> +     } else if ((!opt->force_editor && !opt->message_given && 
> is_null_oid(prev))
> +               || (opt->force_editor && opt->use_editor)) {
> +             /* Editor must be opened */

If there is no --[no-]edit and there is no preexisting message, we
need to use the editor.  If the command line explicitly said --edit,
we also would use the editor.  OK.

But it starts to make me wonder if you rather want to replace the
single bit use_editor field with an enum with three possible values
(enum { EDITOR_UNSPECIFIED, EDITOR_YES, EDITOR_NO } use_editor).

>               prepare_tag_template(buf, opt, prev, path, tag);
>               if (launch_editor(path, buf, NULL)) {
>                       fprintf(stderr,
>                       _("Please supply the message using either -m or -F 
> option.\n"));
>                       exit(1);
>               }
> +     } else if (!opt->message_given) {
> +             /* Tag already exists and user doesn't want to change it */

Are we certain at this point in if/else cascade that prev is a valid
tag?  How?

> +             strbuf_addstr(buf, get_tag_body(prev, NULL));

This NULL tells us something about what I mentioned in my review on 1/3.


> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> index 80eb13d94e..bf43d2c750 100755
> --- a/t/t7004-tag.sh
> +++ b/t/t7004-tag.sh
> @@ -1313,7 +1313,7 @@ test_expect_success GPG,RFC1991 \
>       'reediting a signed tag body omits signature' '
>       echo "rfc1991" >gpghome/gpg.conf &&
>       echo "RFC1991 signed tag" >expect &&
> -     GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
> +     GIT_EDITOR=./fakeeditor git tag -f --edit -s rfc1991-signed-tag $commit 
> &&
>       test_cmp expect actual
>  '
>  
> @@ -1356,7 +1356,7 @@ test_expect_success GPG,RFC1991 \
>  test_expect_success GPG,RFC1991 \
>       'reediting a signed tag body omits signature' '
>       echo "RFC1991 signed tag" >expect &&
> -     GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
> +     GIT_EDITOR=./fakeeditor git tag -f --edit -s rfc1991-signed-tag $commit 
> &&
>       test_cmp expect actual
>  '

Why do these two need explicit --edit option to invoke the editor?
That smells like an unnecessary backward incompatible change.

Thanks.

Reply via email to