All of lore.kernel.org
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Taylor Blau <me@ttaylorr.com>,
	Rasmus Villemoes <rv@rasmusvillemoes.dk>,
	git@vger.kernel.org
Subject: Re: [PATCH] help: allow redirecting to help for aliased command
Date: Wed, 26 Sep 2018 11:09:11 -0700	[thread overview]
Message-ID: <20180926180911.GA63889@syl> (raw)
In-Reply-To: <xmqqtvmcmg2v.fsf@gitster-ct.c.googlers.com>

On Wed, Sep 26, 2018 at 08:30:32AM -0700, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> writes:
>
> >> +help.followAlias::
> >> +	When requesting help for an alias, git prints a line of the
> >> +	form "'<alias>' is aliased to '<string>'". If this option is
> >> +	set to a positive integer, git proceeds to show the help for
> >
> > With regard to "set to a positive integer", I'm not sure why this is the
> > way that it is. I see below you used 'git_config_int()', but I think
> > that 'git_config_bool()' would be more appropriate.
> >
> > The later understands strings like "yes", "on" or "true", which I think
> > is more of what I would expect from a configuration setting such as
> > this.
>
> That is, as you read in the next paragraph, because it gives the
> number of deciseconds to show a prompt before showing the manpage.
>
> Not that I think this configuration is a good idea (see my review).
>
> >> +	the first word of <string> after the given number of
> >> +	deciseconds. If the value of this option is negative, the
> >> +	redirect happens immediately. If the value is 0 (which is the
> >> +	default), or <string> begins with an exclamation point, no
> >> +	redirect takes place.
> >
> > It was unclear to my originlly why this was given as a configuration
> > knob, but my understanding after reading the patch is that this is to do
> > _additional_ things besides printing what is aliased to what.
> >
> > Could you perhaps note this in the documentation?
>
> It may be that the description for the "execute the likely typoed
> command" configuration is poorly written and this merely copied the
> badness from it.  Over there the prompt gives a chance to ^C out,
> which serves useful purpose, and if that is not documented, we should.
>
> On the other hand, I'd rather see this prompt in the new code
> removed, because I do not think the prompt given in the new code
> here is all that useful.
>
> >> @@ -415,9 +420,34 @@ static const char *check_git_cmd(const char* cmd)
> >>
> >>  	alias = alias_lookup(cmd);
> >>  	if (alias) {
> >> -		printf_ln(_("'%s' is aliased to '%s'"), cmd, alias);
> >> -		free(alias);
> >> -		exit(0);
> >> +		const char **argv;
> >> +		int count;
> >> +
> >> +		if (!follow_alias || alias[0] == '!') {
> >> +			printf_ln(_("'%s' is aliased to '%s'"), cmd, alias);
> >> +			free(alias);
> >> +			exit(0);
> >> +		}
> >> +		fprintf_ln(stderr, _("'%s' is aliased to '%s'"), cmd, alias);
> >
> > OK, I think that this is a sensible decision: print to STDERR when
> > that's not the main purpose of what're doing (e.g., we're going to
> > follow the alias momentarily), and STDOUT when it's the only thing we're
> > doing.
>
> > Potentially we could call 'fprintf_ln()' only once, and track an `int
> > fd` at the top of this block.
>
> I actually think this should always give the output to standard output.
>
> >> +
> >> +		/*
> >> +		 * We use split_cmdline() to get the first word of the
> >> +		 * alias, to ensure that we use the same rules as when
> >> +		 * the alias is actually used. split_cmdline()
> >> +		 * modifies alias in-place.
> >> +		 */
> >> +		count = split_cmdline(alias, &argv);
> >> +		if (count < 0)
> >> +			die("Bad alias.%s string: %s", cmd,
> >> +			    split_cmdline_strerror(count));
> >
> > Please wrap this in _() so that translators can translate it.
> >
> >> +		if (follow_alias > 0) {
> >> +			fprintf_ln(stderr,
> >> +				   _("Continuing to help for %s in %0.1f seconds."),
> >> +				   alias, follow_alias/10.0);
> >> +			sleep_millisec(follow_alias * 100);
> >> +		}
> >> +		return alias;
> >
> > I'm not sure that this notification is necessary, but I'll defer to the
> > judgement of others on this one.
>
> I didn't bother to check the original but this is mimicking an
> existing code that lets configuration to be set to num-deciseconds
> to pause and give chance to ^C out, and also allows it to be set to
> negative to immediately go ahead.  follow-alias at this point cannot
> be zero in the codeflow, but it still can be negative.

I think that this is the most compelling argument _for_ the configuration
that you are not in favor of. I understood your previous review as "I
know that 'git cp' is a synonym of 'git cherry-pick', but I want to use
'git co --help' for when I don't remember what 'git co' is a synonym
of."

This pause (though I'm a little surprised by it when reviewing the
code), I think strikes a good balance between the two, i.e., that you
can get help for whatever it is aliased to, and see what that alias is.

Thanks,
Taylor

  reply	other threads:[~2018-09-26 18:09 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 10:26 [PATCH] help: allow redirecting to help for aliased command Rasmus Villemoes
2018-09-26 14:37 ` Taylor Blau
2018-09-26 15:19   ` Duy Nguyen
2018-09-28  7:44     ` Rasmus Villemoes
2018-09-26 15:30   ` Junio C Hamano
2018-09-26 18:09     ` Taylor Blau [this message]
2018-09-26 18:20       ` Junio C Hamano
2018-09-26 15:16 ` Duy Nguyen
2018-09-26 15:16 ` Junio C Hamano
2018-09-26 18:12   ` Taylor Blau
2018-09-28  7:53     ` Rasmus Villemoes
2018-09-26 18:49   ` Jeff King
2018-09-26 19:31     ` Junio C Hamano
2018-09-28  8:18     ` Rasmus Villemoes
2018-09-29  8:21       ` Jeff King
2018-09-29 17:39         ` Junio C Hamano
2018-09-30  4:27           ` Jeff King
2018-09-30  5:27             ` Junio C Hamano
2018-09-30  5:53               ` Jeff King
2018-09-28  7:40   ` Rasmus Villemoes
2018-09-28 17:00     ` Junio C Hamano
2018-10-01 11:21 ` [PATCH v2 1/3] help: redirect to aliased commands for "git cmd --help" Rasmus Villemoes
2018-10-01 11:21   ` [PATCH v2 2/3] git.c: handle_alias: prepend alias info when first argument is -h Rasmus Villemoes
2018-10-03  2:16     ` Jeff King
2018-10-01 11:21   ` [PATCH v2 3/3] git-help.txt: document "git help cmd" vs "git cmd --help" for aliases Rasmus Villemoes
2018-10-03  2:18     ` Jeff King
2018-10-03  6:25       ` Rasmus Villemoes
2018-10-03  2:13   ` [PATCH v2 1/3] help: redirect to aliased commands for "git cmd --help" Jeff King
2018-10-03  6:24     ` Rasmus Villemoes
2018-10-03  7:06       ` Jeff King
2018-10-03 11:42   ` [PATCH v3 0/3] alias help tweaks Rasmus Villemoes
2018-10-03 11:42     ` [PATCH v3 1/3] help: redirect to aliased commands for "git cmd --help" Rasmus Villemoes
2018-10-05  8:19       ` Junio C Hamano
2018-10-05 10:22         ` Rasmus Villemoes
2018-10-05 16:47           ` Junio C Hamano
2018-10-03 11:42     ` [PATCH v3 2/3] git.c: handle_alias: prepend alias info when first argument is -h Rasmus Villemoes
2018-10-03 11:42     ` [PATCH v3 3/3] git-help.txt: document "git help cmd" vs "git cmd --help" for aliases Rasmus Villemoes
2018-10-04  0:10     ` [PATCH v3 0/3] alias help tweaks Jeff King
2018-10-09 11:59     ` [PATCH v4 " Rasmus Villemoes
2018-10-09 11:59       ` [PATCH v4 1/3] help: redirect to aliased commands for "git cmd --help" Rasmus Villemoes
2018-10-09 11:59       ` [PATCH v4 2/3] git.c: handle_alias: prepend alias info when first argument is -h Rasmus Villemoes
2018-10-09 11:59       ` [PATCH v4 3/3] git-help.txt: document "git help cmd" vs "git cmd --help" for aliases Rasmus Villemoes
2018-10-12  3:17       ` [PATCH v4 0/3] alias help tweaks Junio C Hamano

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=20180926180911.GA63889@syl \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rv@rasmusvillemoes.dk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.