diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-07-11 18:45:09 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-08-01 15:37:11 -0700 |
commit | af5b5c5efab6329ce8f70495cc5c6a40636f5f4c (patch) | |
tree | 2ea0e25661c442ff72467432fd41f513501ce97e | |
parent | d8cbf77c3ba7f5dd20576d5d2d8022dfd9016537 (diff) | |
download | git-af5b5c5efab6329ce8f70495cc5c6a40636f5f4c.tar.gz |
warn on unusable smudgeToFile/cleanFromFile config
Let the user know when they have a smudgeToFile/cleanFromFile config
that cannot be used because the corresponding smudge/clean config
is missing.
The warning is only displayed a maximum of once per git invocation,
and only when doing an operation that would use the filter.
Signed-off-by: Joey Hess <joeyh@joeyh.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | convert.c | 36 |
1 files changed, 26 insertions, 10 deletions
@@ -849,34 +849,50 @@ int would_convert_to_git_filter_fd(const char *path) return apply_filter(path, NULL, NULL, 0, -1, NULL, ca.drv->clean); } +static int can_filter_file(const char *filefilter, const char *filefiltername, + const char *stdiofilter, const char *stdiofiltername, + const struct conv_attrs *ca, + int *warncount) +{ + if (!filefilter) + return 0; + + if (stdiofilter) + return 1; + + if (*warncount == 0) + warning("Not running your configured filter.%s.%s command, because filter.%s.%s is not configured", + ca->drv->name, filefiltername, + ca->drv->name, stdiofiltername); + *warncount=*warncount+1; + + return 0; +} + int can_clean_from_file(const char *path) { struct conv_attrs ca; + static int warncount = 0; convert_attrs(&ca, path); if (!ca.drv) return 0; - /* - * Only use the cleanFromFile filter when the clean filter is also - * configured. - */ - return (ca.drv->clean_from_file && ca.drv->clean); + return can_filter_file(ca.drv->clean_from_file, "cleanFromFile", + ca.drv->clean, "clean", &ca, &warncount); } int can_smudge_to_file(const char *path) { struct conv_attrs ca; + static int warncount = 0; convert_attrs(&ca, path); if (!ca.drv) return 0; - /* - * Only use the smudgeToFile filter when the smudge filter is also - * configured. - */ - return (ca.drv->smudge_to_file && ca.drv->smudge); + return can_filter_file(ca.drv->smudge_to_file, "smudgeToFile", + ca.drv->smudge, "smudge", &ca, &warncount); } const char *get_convert_attr_ascii(const char *path) |