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

Shouldn't git be able to apply diffs that it created with --ignore-whitespace?

From
Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date
Oct 18, 2018, 20:12 UTC
Message-ID
<CACcTrKfVZsRC8y-89mnj6LnRHnT6ivQCHpc0p5ABXk4kds6MbA@mail.gmail.com>
Hello again all,

I think I've previously broached this subject before, but I think I perhaps wasn't clear enough about what I was trying to do or why I feel that git is at fault here.

(I'm running git 2.19.1)

Starting with a fully-committed, not-dirty codebase, I open(ed) a poorly formatted, mixed-whitespace file (that I absolutely did not author!) under version control and make some very localized changes. My editor, being very smart and helpful, fixes up the line ending on save, and I exit.

At this point, my source file contains a) deliberate changes I want, and b) whitespace changes I wish I could commit but that should not be a part of my patch.

Shouldn't the following workflow be supported:

~> git diff -w > foo.diff ~> git reset --hard ~> git apply [--ignore-whitespace] < foo.diff

Because that throws an error in this case:
> error: patch failed: includes/helpers/class.phpmailer.php:1182
> error: includes/helpers/class.phpmailer.php: patch does not apply

I feel like this did work, once upon a time. Perhaps prior to the same that broke `git add -p` when whitespace was mangled on editor exit/save (2b8ea7f3c7)?

To help debug this, I'm attaching the output of the following taken after I've made my changes to the file and wish to generate a clean diff, the former of which applies just fine after `git reset --hard`, while the latter does not:

~> git diff > with_whitespace.diff ~> git diff -w > without_whitespace.diff

(I can also privately share the original file off-list if needed.)

I don't believe the list allows binary attachments and because we're dealing with line-ending mangling I definitely do not want to include them inline, so I've uploaded them here:

* http://share.neosmart.net/View/Index/nGujqm.diff
* http://share.neosmart.net/View/Index/f4dkVF.diff
(You can download them as-is by clicking the floppy icon in the top-right)
With thanks,

Mahmoud Al-Qudsi NeoSmart Technologies

Next: brian m. carlson
Message 1 of 2 in “Shouldn't git be able to apply diffs that it created with --ignore-whitespace?”
  1. Mahmoud Al-QudsiOct 18, 2018
  2. brian m. carlsonOct 20, 2018

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.