diff options
author | Johan Herland <johan@herland.net> | 2011-04-29 11:36:22 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-04-29 11:22:56 -0700 |
commit | 51670fc87e193a42022087d8d773cf2315736604 (patch) | |
tree | b36c2ff5c0ab9e4315c212f51c7c54226fafa911 /t/t4013/diff.whatchanged_--patch-with-stat_master_--_dir_ | |
parent | New --dirstat=lines mode, doing dirstat analysis based on diffstat (diff) | |
download | tgif-51670fc87e193a42022087d8d773cf2315736604.tar.xz |
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 't/t4013/diff.whatchanged_--patch-with-stat_master_--_dir_')
0 files changed, 0 insertions, 0 deletions