I am not sure if that is done on purpose but I found it a bit confusing.
When running a git command from a non-git repo I get the message:
"fatal: not a git repository (or any of the parent directories): .git"
as expected, but then $LASTEXITCODE return 0. I would expect a non-zero value.
Is that something done on purpose?