{"thread":{"id":"14081","subject":"Why does diff --binary include content of files being deleted?","startedAt":"2008-06-22T03:34:54Z","lastAt":"2008-06-22T04:15:10Z","messageCount":4,"participants":["Allan Wind","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"80586","messageId":"20080622033454.GA10578@lifeintegrity.com","threadId":"14081","inReplyTo":null,"subject":"Why does diff --binary include content of files being deleted?","fromName":"Allan Wind","fromEmail":"allan_wind@lifeintegrity.com","sentAt":"2008-06-22T03:34:54Z","receivedAt":"2008-06-22T03:34:54Z","isPatch":false,"sender":{"key":"allan_wind@lifeintegrity.com","avatar":null},"body":"Between tag1 and tag2 I am deleting a number of binary files, and I was \nsurprised seeing the binaries being added to the diff when said files\nare to be deleted:\n\ngit diff --binary tag1 tag2 > /tmp/diff && ls -l /tmp/diff\n-rw-r--r-- 1 allan users 555135993 2008-06-21 22:37 /tmp/diff\n\ngit diff tag1 tag2 > /tmp/diff2 && ls -l /tmp/diff2\n-rw-r--r-- 1 allan users 12862 2008-06-21 23:33 /tmp/diff2\n\n\n\n/Allan\n"},{"id":"80587","messageId":"20080622035118.GD11793@spearce.org","threadId":"14081","inReplyTo":"20080622033454.GA10578@lifeintegrity.com","subject":"Re: Why does diff --binary include content of files being deleted?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-06-22T03:51:18Z","receivedAt":"2008-06-22T03:51:18Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Allan Wind <allan_wind@lifeintegrity.com> wrote:\n> Between tag1 and tag2 I am deleting a number of binary files, and I was \n> surprised seeing the binaries being added to the diff when said files\n> are to be deleted:\n> \n> git diff --binary tag1 tag2 > /tmp/diff && ls -l /tmp/diff\n> -rw-r--r-- 1 allan users 555135993 2008-06-21 22:37 /tmp/diff\n> \n> git diff tag1 tag2 > /tmp/diff2 && ls -l /tmp/diff2\n> -rw-r--r-- 1 allan users 12862 2008-06-21 23:33 /tmp/diff2\n\nIn order to apply the diff in reverse we need the old binary data\nin the diff output.  So that's why its larger.\n\nIn other words lets say you actually wanted to go back to tag1,\nafter having tag2 for a while:\n\n\t$ git checkout tag2\n\t$ git diff --binary tag1 tag2 | git apply --index -R\n\nwithout the binary data in the diff, apply cannot run in the\nreverse direction to restore back to tag1.  :)\n\n-- \nShawn.\n"},{"id":"80588","messageId":"20080622040536.GA10813@lifeintegrity.com","threadId":"14081","inReplyTo":"20080622035118.GD11793@spearce.org","subject":"Re: Why does diff --binary include content of files being deleted?","fromName":"Allan Wind","fromEmail":"allan_wind@lifeintegrity.com","sentAt":"2008-06-22T04:05:36Z","receivedAt":"2008-06-22T04:05:36Z","isPatch":false,"sender":{"key":"allan_wind@lifeintegrity.com","avatar":null},"body":"On 2008-06-21T23:51:18-0400, Shawn O. Pearce wrote:\n> In order to apply the diff in reverse we need the old binary data\n> in the diff output.  So that's why its larger.\n\nMakes sense, thanks.  In my use case (where I do not need the reverse \ndiff) this adds 500+ MB or 43159% overhead.\n\nWhen I tried to apply the large diff my virtual private server with 512 \nMB of memory git apply ran out of memory and died.  Is there any way to \nbound the memory usage of git apply?\n\n\n/Allan\n"},{"id":"80589","messageId":"20080622041510.GE11793@spearce.org","threadId":"14081","inReplyTo":"20080622040536.GA10813@lifeintegrity.com","subject":"Re: Why does diff --binary include content of files being deleted?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-06-22T04:15:10Z","receivedAt":"2008-06-22T04:15:10Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Allan Wind <allan_wind@lifeintegrity.com> wrote:\n> On 2008-06-21T23:51:18-0400, Shawn O. Pearce wrote:\n> > In order to apply the diff in reverse we need the old binary data\n> > in the diff output.  So that's why its larger.\n> \n> Makes sense, thanks.  In my use case (where I do not need the reverse \n> diff) this adds 500+ MB or 43159% overhead.\n\nWell, then in that case you have to omit --binary I think, or use a\nfilter script to strip out the binary data from the resulting patch.\n\n> When I tried to apply the large diff my virtual private server with 512 \n> MB of memory git apply ran out of memory and died.  Is there any way to \n> bound the memory usage of git apply?\n\nIf you submit patches for it.  ;-)\n\ngit-apply today is meant for applying small patches, like those that\nwould typically be written by a developer hacking on open source\nsoftware.  It tries to be completely atomic; either the entire\npatch applies at once, or the entire patch rejects with no changes\nbeing made to the local directory.  As such it applies everything in\nmemory, and only writes out when we are sure the patch applies clean.\n\nSo no, there isn't a way to make git-apply use less memory.\n\n-- \nShawn.\n"}]}