hiroki yasui <hiroma...@gmail.com> writes:
> .gitconfig file is 
> [alias]
>     am = "!f(){ git commit -am \"$1\";};f"

First, there is no reason for your shell command to define a function
and then call it.  The alias should just execute what is now the body of
the function:

>     am = "!git commit -am \"$1\""

Second, the error message shows that quoting is not having the effect
you want.  You gave git-am the argument >modified something logic< and
the error message shows that Git took >modified something logic< as the
name of a file:

> $ git am "modified something logic"
> something error occurred.
> fatal: could not open 'filepath//modified something logic: No such file or 
>> directory

The string that Git sees for the alias is >git commit -am "$1"<.  So
when you substitute $1 (>modified something logic<) you get:

    git commit -am "modified something logic"

Git puts that string into the shell, the shell spawns a Git subprocess,
and it generates that error.

You would get the effect you want if you write

>     am = "!git commit -am $1"

because then the expanded command is >git commit -sm modified something logic<

What you'd really like is

>     am = "!git commit -am \"$@\""

because then you wouldn't need to quote the three arguments you gave to
git-am into one argument, and it would handle file names with spaces.
But I don't know if Git respects the >"$@"< idiom when it is
substituting arguments into an alias.

In practice, it would probably suffice to write

>     am = "!git commit -am $*"

In any case, flatworm's solution is simpler and works at least as well.


You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to