git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Using '--help' for aliases
@ 2017-06-21 18:41 Kaartic Sivaraam
  2017-06-21 18:55 ` Jeff King
  2017-06-24 17:20 ` brian m. carlson
  0 siblings, 2 replies; 5+ messages in thread
From: Kaartic Sivaraam @ 2017-06-21 18:41 UTC (permalink / raw)
  To: git

Hello all,

I am yet another user of 'git alias' (who wouldn't ?). It has become so
natural to me to use the aliased version that at some point of time I
tried the following,

> $ git co --help
> `git co' is aliased to `checkout'

That made me wonder. Git is able to inform the user that 'co' is
aliased to 'checkout' but isn't it possible for it to take one step
more to display help ? Just wondering if there were any reason for not
doing it.

-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using '--help' for aliases
  2017-06-21 18:41 Using '--help' for aliases Kaartic Sivaraam
@ 2017-06-21 18:55 ` Jeff King
  2017-06-21 19:14   ` Kaartic Sivaraam
  2017-06-24 17:20 ` brian m. carlson
  1 sibling, 1 reply; 5+ messages in thread
From: Jeff King @ 2017-06-21 18:55 UTC (permalink / raw)
  To: Kaartic Sivaraam; +Cc: git

On Thu, Jun 22, 2017 at 12:11:29AM +0530, Kaartic Sivaraam wrote:

> I am yet another user of 'git alias' (who wouldn't ?). It has become so
> natural to me to use the aliased version that at some point of time I
> tried the following,
> 
> > $ git co --help
> > `git co' is aliased to `checkout'
> 
> That made me wonder. Git is able to inform the user that 'co' is
> aliased to 'checkout' but isn't it possible for it to take one step
> more to display help ? Just wondering if there were any reason for not
> doing it.

It could do that. I think we even discussed it at one point, but I
didn't dig up the thread. However, you have the problem that running
"man checkout" is likely to clobber the mention of the alias. So the
question is whether it is more important to tell the user that it's an
alias (and which options the alias is using!), or to show them the
referred command's manpage.

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using '--help' for aliases
  2017-06-21 18:55 ` Jeff King
@ 2017-06-21 19:14   ` Kaartic Sivaraam
  2017-06-22  5:39     ` Samuel Lijin
  0 siblings, 1 reply; 5+ messages in thread
From: Kaartic Sivaraam @ 2017-06-21 19:14 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Wed, 2017-06-21 at 14:55 -0400, Jeff King wrote:
> It could do that. I think we even discussed it at one point,
> but I
> didn't dig up the thread. However, you have the problem that running
> "man checkout" is likely to clobber the mention of the alias. So the
> question is whether it is more important to tell the user that it's
> an
> alias (and which options the alias is using!),
Now, that's something I didn't think of. Does seem to quite an issue as
aliases accept argument this.

I seem to be getting the idea of '--help' just now. All these days, I
was actually considering it to be another way of getting to the man
page of a command. Have to play with it a little to see in what other
ways '--help' could help me! In case there's anything that's so useful
about it that I'm missing, let me know.

>  or to show them the
> referred command's manpage.
> 
> -Peff

-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using '--help' for aliases
  2017-06-21 19:14   ` Kaartic Sivaraam
@ 2017-06-22  5:39     ` Samuel Lijin
  0 siblings, 0 replies; 5+ messages in thread
From: Samuel Lijin @ 2017-06-22  5:39 UTC (permalink / raw)
  To: Kaartic Sivaraam; +Cc: Jeff King, git@vger.kernel.org

You could also just make the alias a bash function that does git help
checkout when you pass the --help flag to the alias.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using '--help' for aliases
  2017-06-21 18:41 Using '--help' for aliases Kaartic Sivaraam
  2017-06-21 18:55 ` Jeff King
@ 2017-06-24 17:20 ` brian m. carlson
  1 sibling, 0 replies; 5+ messages in thread
From: brian m. carlson @ 2017-06-24 17:20 UTC (permalink / raw)
  To: Kaartic Sivaraam; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]

On Thu, Jun 22, 2017 at 12:11:29AM +0530, Kaartic Sivaraam wrote:
> I am yet another user of 'git alias' (who wouldn't ?). It has become so
> natural to me to use the aliased version that at some point of time I
> tried the following,
> 
> > $ git co --help
> > `git co' is aliased to `checkout'
> 
> That made me wonder. Git is able to inform the user that 'co' is
> aliased to 'checkout' but isn't it possible for it to take one step
> more to display help ? Just wondering if there were any reason for not
> doing it.

It's possible to do if "co" is an alias for "checkout", but it works
less well when co is the following[0]:

	co = "!f() { if git checkout -h | grep -qs recurse-submodules; \
		then git checkout --recurse-submodules \"$@\"; \
		else git checkout \"$@\" && git sui; \
		fi; };f"

If this alias were to run on a Git with that option but without checkout
--recurse-submodules, then it would print help and then update
submodles, which isn't what I want.

[0] sui is an alias for submodule update --init.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-24 17:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21 18:41 Using '--help' for aliases Kaartic Sivaraam
2017-06-21 18:55 ` Jeff King
2017-06-21 19:14   ` Kaartic Sivaraam
2017-06-22  5:39     ` Samuel Lijin
2017-06-24 17:20 ` brian m. carlson

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).