git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Help creating git alias

From
ESEugene Sajine <euguess@gmail.com>
Date
Oct 31, 2013, 15:36 UTC
Message-ID
<CAPZPVFYFSBRHThO08LmuN_0fc55gYX-A+Y3=yA_MESko1t6fXQ@mail.gmail.com>
In-Reply-To
<xmqqk3gu9jst.fsf@gitster.dls.corp.google.com>
On Wed, Oct 30, 2013 at 11:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 31 quoted lines
> 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*//\"' -"
>
>
Junio,

Thanks for taking the time - I appreciate that a lot. It does work properly now except there is some difference between the required pathnames:

when i'm in a subfolder in git repo i can say
git log filename

But it seems that if the alias is used i need to specify full path from the root of the repo no matter where i am.

git log a/b/c/filename
the difference is obviously in the working directory
when i add an alias:
pd = "!sh -c 'pwd'"
i get this:

$ git pd /home/users/euguess/repo

$ pwd /home/users/euguess/repo/a/b/c

Is there any way to help that situation?

Thanks, Eugene

Thanks, Eugene

Previous: Junio C HamanoNext: David Aguilar
Message 9 of 15 in “Help creating git alias”
  1. Eugene SajineOct 30, 2013
  2. Andrew ArdillOct 30, 2013
  3. Eugene SajineOct 30, 2013
  4. Ralf ThielowOct 30, 2013
  5. Eugene SajineOct 30, 2013
  6. Junio C HamanoOct 30, 2013
  7. Eugene SajineOct 31, 2013
  8. Junio C HamanoOct 31, 2013
  9. Eugene SajineOct 31, 2013
  10. David AguilarOct 31, 2013
  11. Junio C HamanoOct 31, 2013
  12. David AguilarOct 31, 2013
  13. Eugene SajineOct 31, 2013
  14. Junio C HamanoOct 31, 2013
  15. Eugene SajineOct 31, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.