From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id A1D8220189 for ; Wed, 22 Jun 2016 21:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752276AbcFVVJx (ORCPT ); Wed, 22 Jun 2016 17:09:53 -0400 Received: from kitenet.net ([66.228.36.95]:59272 "EHLO kitenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233AbcFVVJx (ORCPT ); Wed, 22 Jun 2016 17:09:53 -0400 X-Question: 42 Authentication-Results: kitenet.net; dkim=pass (1024-bit key; unprotected) header.d=joeyh.name header.i=@joeyh.name header.b=G6cha5uV; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=joeyh.name; s=mail; t=1466629760; bh=OWvQ91NlP/tpe3mCEG0zeWlTMJFHcZJ0zbEUMQCU7bc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G6cha5uVIkGXrye3zthdMlZSd7XdnnR7gDouMjKfCJfWOm5cavrpCHpDbp/qkD9+f dPrRRYdAqoMbBRy0/0Y0o3lFgivfzxfOP6rtaox6fRKJCwadF4a6PeAOf9eK1ebdYu q60zu7oUSjFVyxDbEIY8u0K3KIGa6cBA2G9kSsGs= From: Joey Hess To: git@vger.kernel.org Cc: Joey Hess Subject: [PATCH v4 5/8] warn on unusable smudgeToFile/cleanFromFile config Date: Wed, 22 Jun 2016 17:09:15 -0400 Message-Id: <1466629758-8035-6-git-send-email-joeyh@joeyh.name> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1466629758-8035-1-git-send-email-joeyh@joeyh.name> References: <1466629758-8035-1-git-send-email-joeyh@joeyh.name> X-Spam-Status: No, score=-95.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_PBL,RCVD_IN_SORBS_DUL, RDNS_DYNAMIC,SPF_SOFTFAIL,URIBL_BLOCKED,USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on kite.kitenet.net Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- convert.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/convert.c b/convert.c index 9dde406..378a3bd 100644 --- a/convert.c +++ b/convert.c @@ -859,32 +859,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) -- 2.9.0.587.ga3bedf2