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