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

Filters and diff vs. status

From
Pietro Battiston <me@pietrobattiston.it>
Date
Oct 26, 2015, 14:54 UTC
Message-ID
<1445871284.2698.43.camel@pietrobattiston.it>
Dear mailing list,

I am using, on specific files, a filter which I created.¹ Often, files being tracked are modified in a way not meant to be reflected in the git history to result in changes to be committed. And sometimes, the following happens:

pietro@debiousci:~/path/to/repo$ git status a_file.ipynb
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working
directory)
	modified:   a_file.ipynb

no changes added to commit (use "git add" and/or "git commit -a") pietro@debiousci:~/path/to/repo$ git diff a_file.ipynb pietro@debiousci:~/path/to/repo$

(notice that no diff shown). Then I wonder what is happening (checking out the file doesn't help, resetting --hard neither), and I try to commit the (apparently unchanged) file . And I get the following:

pietro@debiousci:~/path_to_repo$ git commit a_file.ipynb -m '?!'
[master
c76125a] ?!
 1 file changed, 1 insertion(+), 1 deletion(-)
pietro@debiousci:~/path/to/repo$ git show HEAD
commit c76125a537f88db4ff5d13c97b92e1f01c13bb47
Author: Pietro Battiston <me@pietrobattiston.it>
Date:   Mon Oct 26 13:37:24 2015 +0100
    ?!
diff --git a/a_file.ipynb b/a_file.ipynb
index dfdbd79..61663fb 100644
--- a/notebook/a_file.ipynb        
+++ b/notebook/a_file.ipynb        
@@ -349,4 +349,4 @@
    "metadata": {}
   }
  ]
-}
\ No newline at end of file
+}


Now, I don't particularly care about a newline being present or not at
the end of the file, but the fact that the working tree looks dirty
(forbidding me from doing merges) - and that I don't understand why,
and how to fix this without adding bogus commits, annoys me.
I found an analogous behaviour reported some years ago,² and the
conclusion was "I think that there is a bug. I have observed this as
well with my own clean filter sometimes, but not always. I haven't
found a recipe that reliably exhibits the problem." Apart from that, I
have found no clue of why "git diff" and "git status" do not agree.

Does anybody have any pointer to solve this? I could try to play with
my filter imposing that it adds/doesn't add a newline at the end of its
output, but I am really missing the logic of what is going on on the
git side.

Thanks in advance,

Pietro



¹ I don't want to waste anybody's time (I guess the answer to my
problem is pretty general), but for more details see
 https://github.com/toobaz/ipynb_output_filter , presenting both the
script and the configuration I use.

² 
http://thread.gmane.org/gmane.comp.version-control.git/125378/focus=125
684
Message 1 of 1 in “Filters and diff vs. status”
  1. Pietro BattistonOct 26, 2015

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.