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

Re: git diff: add option for omitting the contents of deletes

From
Jeff King <peff@peff.net>
Date
Feb 28, 2011, 12:23 UTC
Message-ID
<20110228122335.GB5197@sigill.intra.peff.net>
In-Reply-To
<20110228121726.GA5197@sigill.intra.peff.net>
On Mon, Feb 28, 2011 at 07:17:26AM -0500, Jeff King wrote:
Show 21 quoted lines
> > That aspect is similar to -M and -C, though - unless we check the sha1
> > of the blobs before applying the patch (which would be possible for -D
> > also) - do we?
> 
> Yes, I think we do check the sha1s for a "-M" patch. And we should do so
> for a "-D" patch, too. Which would make it just as likely to conflict as
> a version with the actual patch content, _except_ that it relies on the
> recipient having that sha1.
> 
> I don't see how "-D" is any less reversible than -M or -C, though. If I
> get your -D patch, I use the index line to see that the blob went from
> 1234abcd to 0000000, check that we are at 1234abcd, and then delete the
> file. To reverse it, I reinstate 1234abcd from nothing (and conflict if
> the file exists). _Neither_ case works without the sha1.
> 
> So I think the problem is not about "this cannot be reversed" but about
> "the recipient must have your sha1 to make sense of it, in either
> direction". Which is the same case as with "-M" and "-C", and why we
> have long cautioned about their use on mailing lists. But the right rule
> is not "do not use on mailing lists" but rather "do not use on mailing
> lists for projects where the recipients will not be using git to apply".

Actually, thinking on this a bit more, I guess "-M" and "-C" are usable without the sha1. In fact, we don't even provide it for a strict 100% rename, and for a rename-with-patch, you can apply the patch, assuming you have the original file in any form. So they are really about "is your recipient using git", not "is your recipient using git _and_ will he/she have the right sha1".

I do still think that in practice among git users that "-D" patches will be able to be applied. You won't typically be sending a patch to delete something that other people don't have. I would expect most uses of "apply -R" to be reverting an existing delete, which means you will have the sha1.

-Peff
Previous: Jeff KingNext: Michael J Gruber
Message 11 of 32 in “git diff: add option for omitting the contents of deletes”
  1. Mart SõmermaaFeb 26, 2011
  2. Junio C HamanoFeb 26, 2011
  3. Michael J GruberFeb 27, 2011
  4. Mart SõmermaaFeb 27, 2011
  5. Michael J GruberFeb 28, 2011
  6. Mart SõmermaaFeb 28, 2011
  7. Junio C HamanoFeb 27, 2011
  8. Junio C HamanoFeb 27, 2011
  9. Michael J GruberFeb 28, 2011
  10. Jeff KingFeb 28, 2011
  11. Jeff KingFeb 28, 2011
  12. Michael J GruberFeb 28, 2011
  13. Jeff KingFeb 28, 2011
  14. Michael J GruberFeb 28, 2011
  15. Jeff KingFeb 28, 2011
  16. Junio C HamanoFeb 28, 2011
  17. Jeff KingFeb 28, 2011
  18. Junio C HamanoFeb 28, 2011
  19. Junio C HamanoMar 1, 2011
  20. Mart SõmermaaMar 7, 2011
  21. Michael J GruberMar 8, 2011
  22. Junio C HamanoMar 8, 2011
  23. Mart SõmermaaMar 8, 2011
  24. Jeff KingMar 8, 2011
  25. symling diff driver (Was: Re: git diff: add option for omitting the contents of deletes)Michael J Gruber, Feb 28, 2011
  26. Jeff KingFeb 28, 2011
  27. attr: make attributes depend on file typeMichael J Gruber, Feb 28, 2011
  28. Jeff KingFeb 28, 2011
  29. Junio C HamanoFeb 28, 2011
  30. Michael J GruberMar 1, 2011
  31. Mart SõmermaaFeb 28, 2011
  32. Michael J GruberFeb 28, 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.