Re: Help creating git alias
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 31, 2013, 03:54 UTC
- Message-ID
- <xmqqk3gu9jst.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CAPZPVFarK_jKpM2f62mErAmL+mck6EN1QPfHDHqqfJbJ2AfzXg@mail.gmail.com>
Eugene Sajine <euguess@gmail.com> writes:
Show 6 quoted lines
> 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*//\"' -"