git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Two problems on alias of git
@ 2009-05-05 12:42 Kana Natsuno
  2009-05-05 14:03 ` Jakub Narebski
  2009-05-08  9:06 ` Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: Kana Natsuno @ 2009-05-05 12:42 UTC (permalink / raw)
  To: git

Hello.  I found 2 problems on alias of git.


The first one is that git crashes with the following situation.
Without GIT_TRACE, everthing works well.  But with GIT_TRACE=1,
git crashes every time.

---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----
$ git remote show origin
* remote origin
  URL: git://repo.or.cz/git.git
  Remote branch merged with 'git pull' while on branch master
    master
  Tracked remote branches
    html
    maint
    man
    master
    next
    pu
    todo

$ git --version
git version 1.6.2.rc0.90.g0753

$ git show HEAD | grep commit
commit 3536ae331014c68a25c80b3fb530a19c8dee0f11

$ uname -a                   
Darwin foobarbaz 9.6.1 Darwin Kernel Version 9.6.1: Sun Dec 21 19:45:33 PST 2008; root:xnu-1228.9.75~4/RELEASE_I386 i386 i386 MacBook5,2 Darwin

$ git config --get alias.l1
log --pretty=oneline

$ GIT_TRACE=1 git l1         
trace: exec: 'git-l1'
trace: run_command: 'git-l1'
trace: exec 'git-l1' failed: No such file or directory
[1]    41772 segmentation fault  GIT_TRACE=1 git l1
---- >8 ---- >8 ---- >8 ---- >8 ---- >8 ----


The second one is that git doesn't expand a kind of aliases
properly, especially with double quotation marks (").  I used the
following alias recently to list the last 10 commits on HEAD:

[alias]
        lr = !git l1 | head | tac

Then I want to extend this alias to list the last N commits on
a branch with "git lr 20", "git lr master", "git lr master 20",
etc.  So that I wrote the following definition (note that the
actual definition is written in a single line, though the quoted
definition is folded in multiple lines for readability):

[alias]
        lr = !$SHELL -c '
                n=10;
                1="${1:-$n}";
                if ! [ "${1##[0-9]*}" = "" ]; then
                  t="$1";
                  1="${2:-$n}";
                  2="$t";
                fi;
                git --no-pager l1 --reverse -"$1" "${2:-HEAD}"
              ' __dummy__

But it doesn't work because git expands as follows:

$ git config --get alias.lr
!$SHELL -c '1=${1:-10}

Double quotation marks (") are removed and the aliased string is
cut at a random position.  I expect that the aliased string is
passed to system() as-is, but git doesn't so.  Why does git behave
so?  Is it a bug or an intentional behavior?


-- 
To Vim, or not to Vim.
http://whileimautomaton.net/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-05-08  9:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-05 12:42 Two problems on alias of git Kana Natsuno
2009-05-05 14:03 ` Jakub Narebski
2009-05-05 15:11   ` Kana Natsuno
2009-05-05 15:42     ` Jakub Narebski
2009-05-05 16:25       ` Kana Natsuno
2009-05-05 17:01         ` Jakub Narebski
2009-05-08  9:06 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).