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

Re: git filter bug

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 11, 2022, 07:43 UTC
Message-ID
<442e3166-4f18-3ee0-e3bc-d24687471d5c@kdbg.org>
In-Reply-To
<101027c97a9b40ce97192b1cee203b07@deshaw.com>
Am 11.06.22 um 00:19 schrieb Udoff, Marc:
Show 41 quoted lines
> Hi,
> 
> I believe there is a bug in git status that happens when a file
> changes but the filtered version of the file does not. Correctly,
> git diff does not show anything as different and git commit believes
> there is nothing to commit.
> 
> Reproducer:
> $ git init
> $ touch bar
> $ git add bar
> $ git commit -am 'Bar'
> [main (root-commit) dd12b3e] Bar
> 1 file changed, 0 insertions(+), 0 deletions(-)
> create mode 100644 bar
> $ echo -en '\n[filter "noat"]\n     clean = grep -v "@"\n' >> .git/config
> $ cat .git/config 
> [core]
>         repositoryformatversion = 0
>         filemode = true
>         bare = false
>         logallrefupdates = true
> 
> [filter "noat"]
>      clean = grep -v "@"
> $ echo -en 'abc\n@def\nghi\n' > bar 
> $ cat bar 
> abc
> @def
> ghi
> $ echo "* filter=noat" > .gitattributes
> $ git commit -am 'No at bar'
> [main e81ee3b] No at bar
> 2 files changed, 3 insertions(+)
> create mode 100644 .gitattributes
> $ git show HEAD:bar
> abc
> ghi
> $ echo "@another line" >> bar # Add another @ which will be filtered. touch doesn't cause this bug
> $ git status --porcelain
> M bar

git status does not compute differences; it only looks at the stat information, and that is by design for performance reasons. So, IMO, this is working as designed and not a bug.

-- Hannes
Previous: Udoff, MarcNext: Junio C Hamano
Message 2 of 6 in “git filter bug”
  1. Udoff, MarcJun 10, 2022
  2. Johannes SixtJun 11, 2022
  3. Junio C HamanoJun 13, 2022
  4. Johannes SixtJun 13, 2022
  5. Shupak, VitalyJun 14, 2022
  6. Udoff, MarcJun 23, 2022

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.