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 89A8C20189 for ; Wed, 22 Jun 2016 20:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752478AbcFVUWN (ORCPT ); Wed, 22 Jun 2016 16:22:13 -0400 Received: from kitenet.net ([66.228.36.95]:57470 "EHLO kitenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751940AbcFVUWM (ORCPT ); Wed, 22 Jun 2016 16:22:12 -0400 X-Question: 42 Authentication-Results: kitenet.net; dkim=pass (1024-bit key; unprotected) header.d=joeyh.name header.i=@joeyh.name header.b=YY++R9yR; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=joeyh.name; s=mail; t=1466626900; bh=Rh8zs+cplBoMbbQeMv/jInheGqUEBCqjTTSIh7W19/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YY++R9yR162PS3hx2LQKc8oBPO89qze5bzCJYNTv65Vs03T9Oo/ayET4/9WVEt5LV NdQ6hZZ9f+4ySt3KXZUszEu1hlqcfzrNsTpeja6tCP2+ZAESOQN02ZbyjD+gV7rfIz pYBvBqRifluG+26nhnGJpLpKaF3z+zsTxm63R59E= From: Joey Hess To: git@vger.kernel.org Cc: Joey Hess Subject: [PATCH v3 5/8] warn on unusable smudgeToFile/cleanFromFile config Date: Wed, 22 Jun 2016 16:21:30 -0400 Message-Id: <20160622202133.23565-6-joeyh@joeyh.name> X-Mailer: git-send-email 2.9.0.8.gf959b2a In-Reply-To: <20160622202133.23565-1-joeyh@joeyh.name> References: <20160622202133.23565-1-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 bf63ba0..b6a76a9 100644 --- a/convert.c +++ b/convert.c @@ -847,32 +847,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.8.g973eabb.dirty