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

Understanding the diff output in gitk when comparing a commit with working tree

From
tobias.boesch@miele.com <tobias.boesch@miele.com>
Date
Nov 28, 2024, 08:27 UTC
Message-ID
<AS2PR08MB82880324292BB445428393B7E1292@AS2PR08MB8288.eurprd08.prod.outlook.com>
In-Reply-To
<AS2PR08MB82888F1C5AE63BD383E53FE6E1282@AS2PR08MB8288.eurprd08.prod.outlook.com>
Hello everyone,

in gitk one can compare commits by selecting one commit, then right click on another commit and use the different diff options in the context menu. That works great! I found that when comparing a commit with those changes made in the working tree, I don’t understand the following observations I made in the diff output for _some_ files:

- the diff output is not colored in red and green for additions and removals, but in red and bold black (still preceded with “++”, “+-“, “--“ and so on)
- some files show no differences, but an external diff shows that those differences are there
- the index of the diff shows an output like mentioned in the “combined diff” format (see https://git-scm.com/docs/diff-format#_combined_diff_format), and looks like “index NUMBER,NUMBER..NUMER”
Other files show up in a “normal” way; as a diff with red and green highlighted lines for additions and removals and no empty file diffs.
To reproduce this make some more changes in the working tree of a git repo. Then compare an older commit with the working tree in gitk and search for my observations in the diff output.
Can someone please explain me why all this happens?

Best wishes Tobias

------------------------------------------------------------------------------------------------- imperial-Werke oHG, Sitz Bünde, Registergericht Bad Oeynhausen - HRA 4825

Next: Johannes Sixt
Message 1 of 2 in “Understanding the diff output in gitk when comparing a commit with working tree”
  1. tobias.boesch@miele.comNov 28, 2024
  2. Johannes SixtNov 29, 2024

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.