git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
From: Philip Oakley <philipoakley@iee.email>
To: "Jeff King" <peff@peff.net>, "Σταύρος Ντέντος" <stdedos@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: Git alias syntax help
Date: Sat, 28 Mar 2020 17:05:54 +0000
Message-ID: <941494c1-b082-e003-b169-00d4e39ed2f5@iee.email> (raw)
In-Reply-To: <20200115181351.GB4081287@coredump.intra.peff.net>

Hi,

On 15/01/2020 18:13, Jeff King wrote:
> On Wed, Jan 15, 2020 at 01:13:17AM +0200, Σταύρος Ντέντος wrote:
>
>>>> new = "!f() { : git log ; git log \"${1}@{1}..${1}@{0}\" \"$@\" ; } ; f"
>>>> new = !f() { : git log ; git log "${1}@{1}..${1}@{0}" "$@" ; } ; f
>>> Only the first one is correct. In addition to the quotes in the second
>>> one being eaten by the config parser, the unquoted semicolon starts a
>>> comment.
>> Could somehow the latter "become" the correct option?
> Unfortunately not without breaking compatibility of existing config
> files.
>
>> Especially in the case of `!sh`:
>> 1) You need to quote everything after `=` sign ("forced" double quotes), then
>> 2) `sh -c` needs another set (singles are most safe here, I think), and
>> 3) If, for some reason, you need to quote further ("$@" would be a
>> common suspect usually)
> Yes, the quoting can get pretty hairy. If your command is complicated, I
> suggest writing it as a separate script and dropping it into your $PATH
> as git-new. Then "git new" will run it automatically (and it's not even
> any less efficient; it still ends up with a single shell invocation).
>
>> Thank you very much for a complete explaination of all of this .
>>
>> Can some of this be documented somewhere?
>> Are they somewhere and I missed them?
> I think the config syntax around quoting is described in "git help
> config" (see the section Syntax). The shell parts seem out of scope for
> Git's manpages themselves, though it sounds like maybe some examples you
> found could stand to be fixed (and/or to call out the subtlety).
>
>> If nothing more, a link to this e-mail chain either on the wiki (if
>> https://git.wiki.kernel.org/index.php/Aliases is an official page) or
>> on git-alias help (here
>> https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases or in some
>> "advanced" section, which I cannot find)
>>
>> If https://git.wiki.kernel.org/index.php/Aliases is an official page,
>> then: was this written for an earlier version?
>> Could it also be updated?
> I think both of the issues you mentioned have always been true. That
> wiki is open to editing by the world,

I took the liberty of adding a small subsection on quoting based on this
discussion, and adding a link to it. Feedback on my ignorance welcomed ;-)
>  so it's possible that somebody
> just added bad examples (and fixes would be welcome).
>
> I don't know the book content very well. Looking at the page you
> linked, I don't think it says anything _wrong_, but it definitely
> doesn't discuss more advanced alias usage. I suspect that would be a
> welcome addition; they take contributions at
> https://github.com/progit/progit2.
>
> -Peff
Philip


      reply	other threads:[~2020-03-28 17:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 15:21 Σταύρος Ντέντος
2020-01-14 22:28 ` Jeff King
2020-01-14 23:13   ` Σταύρος Ντέντος
2020-01-15 18:13     ` Jeff King
2020-03-28 17:05       ` Philip Oakley [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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=941494c1-b082-e003-b169-00d4e39ed2f5@iee.email \
    --to=philipoakley@iee.email \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=stdedos@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

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git