diff options
author | Jeff King <peff@peff.net> | 2010-10-21 10:45:44 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-10-21 15:43:24 -0700 |
commit | 1f2baa78c61bc99fe82bc62fc6d5a8d307984f3d (patch) | |
tree | d8d6291f68c3dac2d29f41d59c462eb66758cccb /contrib/hg-to-git | |
parent | {cvs,svn}import: use the new 'git read-tree --empty' (diff) | |
download | tgif-1f2baa78c61bc99fe82bc62fc6d5a8d307984f3d.tar.xz |
config: treat non-existent config files as empty
The git_config() function signals error by returning -1 in
two instances:
1. An actual error occurs in opening a config file (parse
errors cause an immediate die).
2. Of the three possible config files, none was found.
However, this second case is often not an error at all; it
simply means that the user has no configuration (they are
outside a repo, and they have no ~/.gitconfig file). This
can lead to confusing errors, such as when the bash
completion calls "git config --list" outside of a repo. If
the user has a ~/.gitconfig, the command completes
succesfully; if they do not, it complains to stderr.
This patch allows callers of git_config to distinguish
between the two cases. Error is signaled by -1, and
otherwise the return value is the number of files parsed.
This means that the traditional "git_config(...) < 0" check
for error should work, but callers who want to know whether
we parsed any files or not can still do so.
[jc: with tests from Jonathan]
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/hg-to-git')
0 files changed, 0 insertions, 0 deletions