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

diff for deleted file only, when changed to directory

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Dec 8, 2010, 08:12 UTC
Message-ID
<AANLkTimXOKC_9TJU1foNkTqPHouFPouzZw3XU_9Za=na@mail.gmail.com>
Hi,

when I stage a file deletion (named foo) and than add a new file (named foo/bar) in a directory with the name of deleted file. git diff --cached -- foo shows me the diff for both the file foo and file foo/bar.

Here is a recipe:

echo foo >f git add f git commit -mfoo git rm f mkdir f echo bar >f/0 git add f/0 git diff -- f git diff --cached -- f

gives me this:
diff --git c/f i/f
deleted file mode 100644
index 257cc56..0000000
--- c/f
+++ /dev/null
@@ -1 +0,0 @@
-foo
diff --git c/f/0 i/f/0
new file mode 100644
index 0000000..5716ca5
--- /dev/null
+++ i/f/0
@@ -0,0 +1 @@
+bar

For the other case, when I stage a symlink under the name foo, I can
understand that git diff shows me two diffs. But for the case
file->directory, I would like to see only the deleted diff, not
recursing into the directory.

Bert
Next: Jonathan Nieder
Message 1 of 4 in “diff for deleted file only, when changed to directory”
  1. Bert WesargDec 8, 2010
  2. Jonathan NiederDec 8, 2010
  3. Bert WesargDec 8, 2010
  4. Nguyen Thai Ngoc DuyDec 8, 2010

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.