Allow setting of git_commit, version, and dirty via shell varables

This is particularly useful if building from a tarball instead of from a
checked out git repo (as all Linux distributions do)
You can use an "or" here:

```
  if [[ -n "${git_commit-}" ]] || git_commit=$(git rev-parse "HEAD^{commit}" 2>/dev/null); then
    ldflags+=(...)
```

Similar in most other cases.

Please use [[ ... ]], -n (instead of ! -z) and quotes around the variables.