git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] convert: legitimately disable clean/smudge filter with an empty override

From
larsxschneider@gmail.com <larsxschneider@gmail.com>
Date
Jan 29, 2016, 08:21 UTC
Message-ID
<1454055697-6742-2-git-send-email-larsxschneider@gmail.com>
In-Reply-To
<1454055697-6742-1-git-send-email-larsxschneider@gmail.com>
From: Lars Schneider <larsxschneider@gmail.com>

If the clean/smudge command of a Git filter driver (filter.<driver>.smudge and filter.<driver>.clean) is set to an empty string ("") and the filter driver is not required (filter.<driver>.required=false) then Git will run successfully. However, Git will print an error for every file that is affected by the filter.

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

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---
 convert.c             |  2 +-
 t/t0021-conversion.sh | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/convert.c b/convert.c
index 814e814..02d5f1e 100644
--- a/convert.c
+++ b/convert.c
@@ -395,7 +395,7 @@ static int apply_filter(const char *path, const char *src, size_t len, int fd,
 	struct async async;
 	struct filter_params params;
 
-	if (!cmd)
+	if (!cmd || !*cmd)
 		return 0;
 
 	if (!dst)
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 718efa0..7bac2bc 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -252,4 +252,20 @@ test_expect_success "filter: smudge empty file" '
 	test_cmp expected filtered-empty-in-repo
 '
 
+test_expect_success 'disable filter with empty override' '
+	test_config_global filter.disable.smudge false &&
+	test_config_global filter.disable.clean false &&
+	test_config filter.disable.smudge false &&
+	test_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_must_be_empty err &&
+	rm -f test.disable &&
+	git -c filter.disable.smudge= checkout -- test.disable 2>err &&
+	test_must_be_empty err
+'
+
 test_done
-- 
2.5.1
Previous: larsxschneider@gmail.comNext: Junio C Hamano
Message 2 of 5 in “convert: legitimately disable clean/smudge filter with an empty override”
  1. convert: legitimately disable clean/smudge filter with an empty overridelarsxschneider@gmail.com, Jan 29, 2016
  2. convert: legitimately disable clean/smudge filter with an empty overridelarsxschneider@gmail.com, Jan 29, 2016
  3. Junio C HamanoJan 29, 2016
  4. Junio C HamanoJan 29, 2016
  5. Lars SchneiderJan 29, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.