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

Re: Why does diff --binary include content of files being deleted?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jun 22, 2008, 03:51 UTC
Message-ID
<20080622035118.GD11793@spearce.org>
In-Reply-To
<20080622033454.GA10578@lifeintegrity.com>
Allan Wind <allan_wind@lifeintegrity.com> wrote:
Show 9 quoted lines
> Between tag1 and tag2 I am deleting a number of binary files, and I was 
> surprised seeing the binaries being added to the diff when said files
> are to be deleted:
> 
> git diff --binary tag1 tag2 > /tmp/diff && ls -l /tmp/diff
> -rw-r--r-- 1 allan users 555135993 2008-06-21 22:37 /tmp/diff
> 
> git diff tag1 tag2 > /tmp/diff2 && ls -l /tmp/diff2
> -rw-r--r-- 1 allan users 12862 2008-06-21 23:33 /tmp/diff2

In order to apply the diff in reverse we need the old binary data in the diff output. So that's why its larger.

In other words lets say you actually wanted to go back to tag1, after having tag2 for a while:

	$ git checkout tag2
	$ git diff --binary tag1 tag2 | git apply --index -R

without the binary data in the diff, apply cannot run in the reverse direction to restore back to tag1. :)

-- 
Shawn.
Previous: Allan WindNext: Allan Wind
Message 2 of 4 in “Why does diff --binary include content of files being deleted?”
  1. Allan WindJun 22, 2008
  2. Shawn O. PearceJun 22, 2008
  3. Allan WindJun 22, 2008
  4. Shawn O. PearceJun 22, 2008

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.