git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Steffen Prohaska <prohaska@zib.de>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v2] completion: Handle '!f() { ... }; f' aliases
Date: Mon, 09 Jun 2014 22:27:36 -0700	[thread overview]
Message-ID: <xmqq1tuxcp13.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1402318493-29943-1-git-send-email-prohaska@zib.de> (Steffen Prohaska's message of "Mon, 9 Jun 2014 14:54:53 +0200")

Steffen Prohaska <prohaska@zib.de> writes:

> '!f() { ... }; f' is a recommended pattern to declare more complex
> aliases (see git wiki [1]).  This commit teaches the completion to
> handle them.

Hmm, I've never endorsed nor recommended such a notation myself ;-)
I tend to prefer writing it like so instead:

    sh -c '...' -

so that I won't clobber "f" (or any other name).  I wonder if you
can help users of this other pattern as well.

> When determining which completion to use for an alias, the opening brace
> is now ignored in order to continue the search for a git command inside
> the function body.  For example, the alias '!f() { git commit ... }' now
> triggers commit completion.

I suspect that "scanning" is error-prone.  I like this one for its
cuteness very much, though:

> Furthermore, the null command ':' is now skipped, so that it can be used
> as a workaround to declare the desired completion style.  For example,
> the alias '!f() { : git commit ; if ...  ' now triggers commit
> completion.



> +test_expect_success 'completion uses <cmd> completion for alias !f() { VAR=val git <cmd> ... }' '
> +	test_config alias.co "!f() { VAR=val git checkout ... ; } f" &&

Is it only "f" that is completed, or can I spell it using another
arbitrary token, e.g.

	test_config alias.co "!co () { git checkout ... } co"

  reply	other threads:[~2014-06-10  5:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-07 14:10 [PATCH] completion: Handle '!f() { ... }; f' aliases Steffen Prohaska
2014-06-08  9:02 ` Eric Sunshine
2014-06-09 12:54   ` [PATCH v2] " Steffen Prohaska
2014-06-10  5:27     ` Junio C Hamano [this message]
2014-06-12 18:41       ` Steffen Prohaska
2014-06-12 18:49         ` [PATCH v2] completion: Handle '!f() { ... }; f' and "!sh -c '...'" aliases Steffen Prohaska

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=xmqq1tuxcp13.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=prohaska@zib.de \
    --cc=sunshine@sunshineco.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).