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

Which is wrong? diff or apply?

From
Johannes Sixt <j6t@kdbg.org>
Date
Jul 23, 2010, 19:03 UTC
Message-ID
<201007232103.08870.j6t@kdbg.org>
Today, I tried this in my git.git checkout:
  $ mv transport-helper.c wt-status.c
  $ git diff -B -M | git apply --cached
  error: wt-status.c: already exists in index

That is, I overwrote the tracked wt-status.c with a completly different file that is also tracked. Then I try to stage the change using git apply.

git diff -B -M reports this:
  diff --git a/transport-helper.c b/wt-status.c
  similarity index 100%
  rename from transport-helper.c
  rename to wt-status.c

Notice that there is no mention that the previously existing wt-status.c was removed. I wonder whether this is a bug.

Or is it the safety valve in git apply that does not allow to overwrite an existing file which should not trigger in this case?

-- Hannes
Next: Junio C Hamano
Message 1 of 2 in “Which is wrong? diff or apply?”
  1. Johannes SixtJul 23, 2010
  2. Junio C HamanoJul 23, 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.