From: Bagas Sanjaya <bagasdotme@gmail.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: Git Users <git@vger.kernel.org>, Jakub Wilk <jwilk@jwilk.net>,
Jonathan Nieder <jrnieder@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: git tag -h fatal error with global tag.sort config
Date: Mon, 18 Oct 2021 12:24:26 +0700 [thread overview]
Message-ID: <cc1b7611-8ec1-db29-1678-f45ba08d9b68@gmail.com> (raw)
In-Reply-To: <20210912132757.GC76263@szeder.dev>
On 12/09/21 20.27, SZEDER Gábor wrote:
> Interesting. It bisects to 47bd3d0c14 (ref-filter: don't look for
> objects when outside of a repository, 2018-11-14), which, based on the
> error message, kind of makes sense, because 'git tag' uses the general
> ref-filter sorting facility. Now, even if 'git tag -h' is executed in
> a repository, since 99caeed05d (Let 'git <command> -h' show usage
> without a git dir, 2009-11-09) run_builtin() special-cases the '-h'
> option and does not call setup_git_directory(), so cmd_tag() and
> everything invoked from within will mistakenly think that there is no
> repository. And cmd_tag() parses the config before parsing the
> options (of course, otherwise command line options couldn't override
> the config), so it hits this die() before parse_options would get a
> change to act on the '-h' option.
>
> Now, 'git branch' uses the same ref-filter sorting, but the equivalent
> 'git -c branch.sort=creatordate branch -h' command does show the usage
> as expected. The relevant difference between cmd_branch() and
> cmd_tag() is that the former special-cases the '-h' option as well
> just before it would call git_config(). Doing the same in cmd_tag()
> like in the patch below seems to fix this issue, but I'm not sure that
> this is the right fix.
>
>
> --- >8 ---
>
> diff --git a/builtin/tag.c b/builtin/tag.c
> index 065b6bf093..31b8cc4600 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -485,6 +485,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
>
> setup_ref_filter_porcelain_msg();
>
> + if (argc == 2 && !strcmp(argv[1], "-h"))
> + usage_with_options(git_tag_usage, options);
> +
> git_config(git_tag_config, sorting_tail);
>
> memset(&opt, 0, sizeof(opt));
>
Sorry for long reply.
Patch applied and usage help appears.
But when I do `./bin-wrappers/git tag -h`, I don't see `usage:` header,
and instead show the help starting from `-F`.
--
An old man doll... just what I always wanted! - Clara
prev parent reply other threads:[~2021-10-18 5:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-12 11:28 git tag -h fatal error with global tag.sort config Bagas Sanjaya
2021-09-12 13:27 ` SZEDER Gábor
2021-09-12 21:39 ` Jeff King
2021-09-13 4:37 ` Bagas Sanjaya
2021-10-18 5:24 ` Bagas Sanjaya [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc1b7611-8ec1-db29-1678-f45ba08d9b68@gmail.com \
--to=bagasdotme@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=jwilk@jwilk.net \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).