public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Eugene Sajine <euguess@gmail•com>
Cc: Ralf Thielow <ralf.thielow@gmail•com>, git <git@vger•kernel.org>,
	Andrew Ardill <andrew.ardill@gmail•com>
Subject: Re: Help creating git alias
Date: Wed, 30 Oct 2013 20:54:42 -0700	[thread overview]
Message-ID: <xmqqk3gu9jst.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAPZPVFarK_jKpM2f62mErAmL+mck6EN1QPfHDHqqfJbJ2AfzXg@mail.gmail.com> (Eugene Sajine's message of "Wed, 30 Oct 2013 21:26:52 -0400")

Eugene Sajine <euguess@gmail•com> writes:

> That was my initial intention, because I would like to be able to pass
> parameters like to git log or git blame correctly without the explicit
> use of $1. Could you please advise about how to make it work with the
> !sh -c ?
>
> Because the same exact (sed 's/@\\S*//') syntax didn't work with "sh -c".

You can make it work if you think step-by-step.  First, this is what
you want to run:

	sh -c 'git log --format="..." "$@" | sed "s/@\S*//"' -

so that "git euguess master..next" would turn into

	sh -c 'git log --format="..." "$@" | sed "s/@\S*//"' - master..next

Now, you want to wrap it into an alias, i.e.

	[alias]
        	euguess = "!sh -c ..."

That ... part is read by our configuration reader, so you need to
quote the double quotes and backslashes with backslash, which would
give you something like:

	[alias]
		euguess = "!sh -c 'git log --format=\"%h %ae %s\" --date=short \"$@\" | sed \"s/@\\S*//\"' -"

  reply	other threads:[~2013-10-31  3:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30 19:34 Help creating git alias Eugene Sajine
2013-10-30 19:47 ` Andrew Ardill
2013-10-30 19:53   ` Eugene Sajine
2013-10-30 19:57 ` Ralf Thielow
2013-10-30 20:10   ` Eugene Sajine
2013-10-30 21:02     ` Junio C Hamano
2013-10-31  1:26       ` Eugene Sajine
2013-10-31  3:54         ` Junio C Hamano [this message]
2013-10-31 15:36           ` Eugene Sajine
2013-10-31 17:40             ` David Aguilar
2013-10-31 18:07               ` Junio C Hamano
2013-10-31 18:15                 ` David Aguilar
2013-10-31 19:31                   ` Eugene Sajine
2013-10-31 19:41                     ` Junio C Hamano
2013-10-31 20:06                       ` Eugene Sajine

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=xmqqk3gu9jst.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=andrew.ardill@gmail$(echo .)com \
    --cc=euguess@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=ralf.thielow@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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