Two problems on alias of git

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]