From: Joey Hess <id@joeyh.name>
To: git@vger.kernel.org
Subject: buggy smudge/clean of empty files
Date: Thu, 22 May 2025 15:01:38 -0400 [thread overview]
Message-ID: <aC90kn2mE93DCJEH@kitenet.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]
git seems to be buggy in its handling of empty files when smudge/clean filters
are used.
I've attached a script setup_smudge_clean.sh, which configures a git
repository to use a very simple smudge and clean filter pair for all
files. The clean filter prepends a line "hi" to the file content, and the
smudge filter removes the line. There is nothing very special about this
smudge/clean, it's just a simple one for the sake of an example.
Here's the bug:
# git init repo
# cd repo
# sh ~/setup_smudge_clean.sh
# echo foo > foofile
# git add foofile
# git diff
# touch emptyfile
# git add emptyfile
# git commit -m added
# git status
On branch master
nothing to commit, working tree clean
# git diff
diff --git a/emptyfile b/emptyfile
--- a/emptyfile
+++ b/emptyfile
@@ -1 +0,0 @@
-hi
emptyfile is unchanged, as git status shows, so why is git diff displaying
a change?
It seems that git diff runs the clean filter (GIT_TRACE shows it does),
but it must ignore its output when the file is empty, and always use an empty
file as the current content for the diff. Which differs from what was staged.
--
see shy jo
[-- Attachment #2: setup_smudge_clean.sh --]
[-- Type: application/x-sh, Size: 321 bytes --]
next reply other threads:[~2025-05-22 19:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-22 19:01 Joey Hess [this message]
2025-05-22 22:15 ` buggy smudge/clean of empty files Jeff King
2025-05-22 22:26 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aC90kn2mE93DCJEH@kitenet.net \
--to=id@joeyh.name \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).