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

reset reports file as modified when it's in fact deleted

From
Carlos Martín Nieto <cmn@elego.de>
Date
Nov 7, 2011, 09:43 UTC
Message-ID
<20111107094330.GB10936@beez.lab.cmartin.tk>
Hello,

When I delete a file (git rm) and then reset so it exists in the index again, the message tells me 'M file.txt' even though the file doesn't exist in the worktree anymore. Running git status afterwards does give the correct output. So, here's the minimal steps to reproduce:

    $ git init
    Initialized empty Git repository in /home/carlos/test/reset-err/.git/
    $ touch file.txt
    $ git add file.txt
    $ git ci file.txt -m initial
    [master (root-commit) a536393] initial
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 file.txt
    $ git rm file.txt
    rm 'file.txt'
    $ git reset -- file.txt
    Unstaged changes after reset:
    M		 file.txt
    $ git status -b -s
    ## master
     D file.txt

I'd expect the output after "Unstaged changes after reset" to tell me file.txt has been deleted instead of modified. This happens with 1.7.8-rc0, 1.7.7 and 1.7.4.1 and I expect with many more that I don't have here.

I thought the index diff code might have been checking the index at the wrong time, but I can run 'git reset HEAD -- file.txt' as many times as I want, and it will still say 'M', so now I'm not sure.

   cmn
Next: Jeff King
Message 1 of 18 in “reset reports file as modified when it's in fact deleted”
  1. Carlos Martín NietoNov 7, 2011
  2. Jeff KingNov 7, 2011
  3. Carlos Martín NietoNov 11, 2011
  4. Junio C HamanoNov 11, 2011
  5. Jeff KingNov 11, 2011
  6. Junio C HamanoNov 12, 2011
  7. Jeff KingNov 14, 2011
  8. 1/4 refresh_index: rename format variablesJeff King, Nov 14, 2011
  9. 2/4 refresh_index: mark deletions in porcelain outputJeff King, Nov 14, 2011
  10. 3/4 read-cache: let refresh_cache_ent pass up changed flagsJeff King, Nov 14, 2011
  11. 4/4 refresh_index: notice typechanges in outputJeff King, Nov 14, 2011
  12. Junio C HamanoNov 15, 2011
  13. Jeff KingNov 15, 2011
  14. Jeff KingNov 18, 2011
  15. 1/3 read-cache: let refresh_cache_ent pass up changed flagsJeff King, Nov 18, 2011
  16. 2/3 refresh_index: rename format variablesJeff King, Nov 18, 2011
  17. 3/3 refresh_index: make porcelain output more specificJeff King, Nov 18, 2011
  18. Junio C HamanoNov 18, 2011

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.