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

Re: Weird behavior of shell variables in git aliases

From
Dun Peal <dunpealer@gmail.com>
Date
Mar 22, 2011, 15:06 UTC
Message-ID
<e81763ce-b933-40ca-b624-adfb26653ac9@s18g2000prg.googlegroups.com>
In-Reply-To
<AANLkTin_qX2S+orrj25=GjB6kf8B6GRSE+HVFUAkDGSb@mail.gmail.com>
Thanks a lot for the explanations, I was really wondering about that.

Incidentally, I had a real reason to prefer using the `!echo...` syntax over the `!sh -c 'echo...'` one; I need my users to define the following alias:

    git checkout $1 && git submodule foreach 'git checkout $sha1'

Due to the necessity of single-quoting the `foreach` expression, I couldn't define it with the `!sh -c` syntax. And because of the problems discussed in this thread, I still don't know how to have my users define this alias.

Thanks, D.

P.S. Incidentally, this alias is addressing a pitfall in the use of submodules that I think should not exist in the first place:

If a repo has a submodule, and head 'foo' of the repo has the submodule's HEAD pointing to head 'foo' of its origin, while head 'bar' of the repo has the submodule HEAD pointing to head 'bar' of its origin, checking out bar/foo on the repository leaves the submodule in an outdated state (and `submodule update` doesn't help).

Previous: Lasse MakholmNext: Junio C Hamano
Message 14 of 20 in “Weird behavior of shell variables in git aliases”
  1. Dun PealMar 21, 2011
  2. Jeff KingMar 21, 2011
  3. Junio C HamanoMar 21, 2011
  4. Junio C HamanoMar 21, 2011
  5. Lasse MakholmMar 22, 2011
  6. Jeff KingMar 22, 2011
  7. Lasse MakholmMar 22, 2011
  8. Ævar Arnfjörð BjarmasonMar 22, 2011
  9. Jeff KingMar 22, 2011
  10. Jeff KingMar 22, 2011
  11. Lasse MakholmMar 22, 2011
  12. Jeff KingMar 22, 2011
  13. Lasse MakholmMar 22, 2011
  14. Dun PealMar 22, 2011
  15. Junio C HamanoMar 22, 2011
  16. Jeff KingMar 22, 2011
  17. Lasse MakholmMar 22, 2011
  18. Junio C HamanoMar 23, 2011
  19. Junio C HamanoMar 22, 2011
  20. Junio C HamanoMar 22, 2011

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.