git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] convert: legitimately disable clean/smudge filter with an empty override
@ 2016-01-24 12:22 larsxschneider
  2016-01-24 15:06 ` Torsten Bögershausen
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: larsxschneider @ 2016-01-24 12:22 UTC (permalink / raw)
  To: git; +Cc: peff, jehan, Lars Schneider

From: Lars Schneider <larsxschneider@gmail.com>

A clean/smudge filter can be disabled if set to an empty string. However,
Git will try to run the empty string as command which results in a error
message per processed file.

Teach Git to consider an empty clean/smudge filter as legitimately disabled
and do not print an error message.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---
 convert.c             |  4 ++--
 t/t0021-conversion.sh | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/convert.c b/convert.c
index 814e814..58af965 100644
--- a/convert.c
+++ b/convert.c
@@ -786,7 +786,7 @@ int convert_to_git(const char *path, const char *src, size_t len,
 	struct conv_attrs ca;

 	convert_attrs(&ca, path);
-	if (ca.drv) {
+	if (ca.drv && ca.drv->clean && strlen(ca.drv->clean)) {
 		filter = ca.drv->clean;
 		required = ca.drv->required;
 	}
@@ -835,7 +835,7 @@ static int convert_to_working_tree_internal(const char *path, const char *src,
 	struct conv_attrs ca;

 	convert_attrs(&ca, path);
-	if (ca.drv) {
+	if (ca.drv && ca.drv->smudge && strlen(ca.drv->smudge)) {
 		filter = ca.drv->smudge;
 		required = ca.drv->required;
 	}
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 718efa0..56e385c 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -252,4 +252,18 @@ test_expect_success "filter: smudge empty file" '
 	test_cmp expected filtered-empty-in-repo
 '

+test_expect_success 'disable filter with empty override' '
+	git config filter.disable.smudge false &&
+	git config filter.disable.clean false &&
+
+	echo "*.disable filter=disable" >.gitattributes &&
+
+	echo test >test.disable &&
+	git -c filter.disable.clean= add test.disable 2>err &&
+	! test -s err &&
+	rm -f test.disable &&
+	git -c filter.disable.smudge= checkout -- test.disable 2>err &&
+	! test -s err
+'
+
 test_done
--
2.5.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-01-28 23:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-24 12:22 [PATCH] convert: legitimately disable clean/smudge filter with an empty override larsxschneider
2016-01-24 15:06 ` Torsten Bögershausen
2016-01-24 21:35   ` Eric Sunshine
2016-01-27  9:49     ` Lars Schneider
2016-01-27  9:42   ` Lars Schneider
2016-01-24 21:45 ` Jeff King
2016-01-27  9:50   ` Lars Schneider
2016-01-25  1:25 ` Junio C Hamano
2016-01-28  9:27   ` Lars Schneider
2016-01-28 22:06     ` Junio C Hamano
2016-01-28 23:51 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).