sourcegraph / go-vcs

manipulate and inspect VCS repositories in Go
https://sourcegraph.com/sourcegraph/go-vcs
Other
79 stars 20 forks source link

vcs/gitcmd: Always provide -- separator. #102

Closed dmitshur closed 6 years ago

dmitshur commented 6 years ago

The -- separator is optional, but always providing it helps avoid arguments being ambiguous in some situations.

Below is an example of when the head commit does not exist.

Before:

exec `git log` failed: exit status 128. Output was:

fatal: ambiguous argument 'notexist': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

After:

exec `git log` failed: exit status 128. Output was:

fatal: bad revision 'notexist'

The new error is better because we can map it to vcs.ErrCommitNotFound rather than a generic unknown error type. This is left for a future PR.

slimsag commented 6 years ago

LGTM, thanks!