summaryrefslogtreecommitdiff
path: root/test-dump-cache-tree.c
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2011-04-29 09:36:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-04-29 18:22:56 (GMT)
commit51670fc87e193a42022087d8d773cf2315736604 (patch)
treeb36c2ff5c0ab9e4315c212f51c7c54226fafa911 /test-dump-cache-tree.c
parent1c57a627bf269f3c83c48ad724cd8b14292502ef (diff)
downloadgit-51670fc87e193a42022087d8d773cf2315736604.zip
git-51670fc87e193a42022087d8d773cf2315736604.tar.gz
git-51670fc87e193a42022087d8d773cf2315736604.tar.bz2
Improve error handling when parsing dirstat parameters
When encountering errors or unknown tokens while parsing parameters to the --dirstat option, it makes sense to die() with an error message informing the user of which parameter did not make sense. However, when parsing the diff.dirstat config variable, we cannot simply die(), but should instead (after warning the user) ignore the erroneous or unrecognized parameter. After all, future Git versions might add more dirstat parameters, and using two different Git versions on the same repo should not cripple the older Git version just because of a parameter that is only understood by a more recent Git version. This patch fixes the issue by refactoring the dirstat parameter parsing so that parse_dirstat_params() keeps on parsing parameters, even if an earlier parameter was not recognized. When parsing has finished, it returns zero if all parameters were successfully parsed, and non-zero if one or more parameters were not recognized (with appropriate error messages appended to the 'errmsg' argument). The parse_dirstat_params() callers then decide (based on the return value from parse_dirstat_params()) whether to warn and ignore (in case of diff.dirstat), or to warn and die (in case of --dirstat). The patch also adds a couple of tests verifying the correct behavior of --dirstat and diff.dirstat in the face of unknown (possibly future) dirstat parameters. Suggested-by: Junio C Hamano <gitster@pobox.com> Improved-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'test-dump-cache-tree.c')
0 files changed, 0 insertions, 0 deletions