I got an error two hours ago from this alias in the .gitconfig file, which is:
[alias]
chist = log --graph -10 --pretty=format:"%C(cyan)%h%Creset %<(20,trunc)%s %Cgreen%<(11,trunc)%an%Creset %as %C(yellow)%G?%Creset %<(5,trunc)%GT %Cred%d"
The error:
$ git chist
fatal: ambiguous argument '%<(20,trunc)%s': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
It seems that the pair of double quotation marks disappeared and $<(20,trunc)%s was treated as an argument to the git log subcommand.
However, If I replaced " with ', the alias would make a desired behavior.
So I have referred to the following documents in order to resolve my question:
According to the first link, the syntax is name = value and if value needed to have leading or trailing spaces, value should be quoted with ". However, in the case of chist, since its value starts with log --graph..., its value itself is not quoted with ", isn't it? So I think this rule can't be applied to my situation.
In the second link, it says "the usual shell quoting" is supported. So I made a following test:
test = abc"def"ghi
text = abc'def'ghi
Let's see how it is parsed:
$ git config --list | grep "alias"
alias.test=abcdefghi
alias.text=abc'def'ghi
I'm afraid this is a contradiction. It's because, if the usual shell quoting were supported, then the value of alias.text should be abcdefghi.
.gitconfigfile? When using the appropriate commands to add/modify/remove aliases withgit config <alias.name> '<effect>'you don't have to wonder about how things are quoted (apart from maybe some rare edge cases).