diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-12-25 02:18:05 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-26 11:37:45 -0800 |
commit | c8deb5a14686c9c2d0ca1e8f42aec8ed44d16954 (patch) | |
tree | ae9c98bbc7b7d04448909a70ffafcf2af83b6749 /t/t1300-repo-config.sh | |
parent | 3a969ef1d67e3b3a26c36cfbe94f6dba05d6dc69 (diff) | |
download | git-c8deb5a14686c9c2d0ca1e8f42aec8ed44d16954.tar.gz git-c8deb5a14686c9c2d0ca1e8f42aec8ed44d16954.tar.xz |
Improve error messages when int/long cannot be parsed from config
If a config file has become mildly corrupted due to a missing LF
we may discover some other option joined up against the end of a
numeric value. For example:
[section]
number = 1auto
where the "auto" flag was meant to occur on the next line, below
"number", but the missing LF has caused it to no longer be its
own option. Instead the word "auto" is parsed as a 'unit factor'
for the value of "number".
Before this change we got the confusing error message:
fatal: unknown unit: 'auto'
which told us nothing about where the problem appeared. Now we get:
fatal: bad config value for 'aninvalid.unit'
which at least points the user in the right direction of where to
search for the incorrectly formatted configuration file.
Noticed by erikh on #git, which received the original error from
a simple `git checkout -b` due to a midly corrupted config.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1300-repo-config.sh')
-rwxr-xr-x | t/t1300-repo-config.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index e894629e7..42eac2a7c 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -448,6 +448,23 @@ test_expect_success numbers ' test z1048576 = "z$m" ' +cat > expect <<EOF +fatal: bad config value for 'aninvalid.unit' in .git/config +EOF + +test_expect_success 'invalid unit' ' + + git config aninvalid.unit "1auto" && + s=$(git config aninvalid.unit) && + test "z1auto" = "z$s" && + if git config --int --get aninvalid.unit 2>actual + then + echo config should have failed + false + fi && + cmp actual expect +' + cat > expect << EOF true false |