Re: [PATCH] builtin/whoami: add new 'whoami' command
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 25, 2026, 21:41 UTC
- Message-ID
- <xmqq7bldlvxk.fsf@gitster.g>
- In-Reply-To
- <pull.2388.git.git.1787690802942.gitgitgadget@gmail.com>
"Andrew Pleeter via GitGitGadget" <gitgitgadget@gmail.com> writes:
> builtin/whoami: add new 'whoami' command
In general, I would really really want to see us refrain from adding any more random subcommands.
Show 7 quoted lines
> +`-a`:: > +`--author`:: > + Show author identity. > + > +`-c`:: > +`--committer`:: > + Show committer identity.
This pair hints the users they are equals.
But the code tells us otherwise:
Show 8 quoted lines
> + if (show_name) {
> + if (show_author)
> + puts(author_name.buf);
> + else
> + puts(committer_name.buf);
> + goto cleanup;
> + }
> +So when "-n" is in effect, "-c" is completely ignored. Lack of "-a" means "-c" instead. The same story holds for "-e".
Yet later in the code that is executed when neither "-n" or "-e" is in effect:
Show 10 quoted lines
> + if (show_author) {
> + puts(author_info.buf);
> + goto cleanup;
> + }
> +
> + if (show_committer) {
> + puts(committer_info.buf);
> + goto cleanup;
> + }
> +Here, lack of "-a" is not sufficient to view committer information and you'd explicitly need to pass "-c" if you want to view committer information.
So confusing.
Show 7 quoted lines
> +`-n`:: > +`--name`:: > + Show name only. > + > +`-e`:: > +`--email`:: > + Show email only.
Why not make -a/-c/-n/-e more additive instead? Something along the lines of ...
$ git ident -a -e -n
Andrew Pleeter <andrewpleeter@gmail.com>
$ git ident -a -n -v
Author: Andrew Pleeter
$ git ident -a -c -e
<andrewpleeter@gmail.com>
<andrewpleeter@gmail.com>
$ git ident -a -c -e -v
Author: <andrewpleeter@gmail.com>
Committer: <andrewpleeter@gmail.com>