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

Comparing the working tree with a commit should be independent of the index

From
MMaaartin <grajcar@seznam.cz>
Date
Aug 18, 2012, 18:36 UTC
Message-ID
<502FE0C6.6050106@seznam.cz>
I've already posted it to SO [1], but got no satisfactory answer. The command
git diff mycommit
compares the working tree against mycommit, so it should not depend on the index. But it does as this example shows:

git init echo A > A.txt; git add .; git commit -m A; git branch A echo B > B.txt; git add .; git commit -m B; git branch B git reset --hard A echo BB > B.txt git diff B

File B.txt exists both in the working tree and in the commit B, so a proper diff should be shown.
Instead I get "deleted file". Adding the file to the index changes it. This is IMHO a bug.
[1]: http://stackoverflow.com/questions/8452820/how-to-compare-the-working-tree-with-a-commit
Next: Junio C Hamano
Message 1 of 4 in “Comparing the working tree with a commit should be independent of the index”
  1. MaaartinAug 18, 2012
  2. Junio C HamanoAug 18, 2012
  3. MaaartinAug 20, 2012
  4. Junio C HamanoAug 20, 2012

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.