gitgit-patchgit-apply

How to apply a git patch without recreating the original structure where it was made


I'm trying to apply this patch to a file (bi_janrain_data/js/bi_janrain_data.js):

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- a/<html>bi_janrain_data.js (<b>Dec 28, 2017 12:15:26 PM</b>)</html>
+++ b/<html><b>Current File</b></html>
@@ -51,25 +51,25 @@
     });

        $('#janDataList_filter').hide();
-       $('.container-inline-date').hide();
+       $('#block-bi-janrain-data-filter-options .container-inline-date').hide();

        $("#edit-filteroption").change(function() {
            if($(this).val() == 'rDate') {              
                $('#janDataList_filter').hide();
-               $('.container-inline-date').show(); 
+               $('#block-bi-janrain-data-filter-options .container-inline-date').show();   

                $('#custom2').val('');
            }
            else if($(this).val() == ''){
                $('#janDataList_filter').hide();
-               $('.container-inline-date').hide();
+               $('#block-bi-janrain-data-filter-options .container-inline-date').hide();
                $('#edit-datestart-datepicker-popup-0').val('');    
                $('#edit-dateend-datepicker-popup-0').val('');
                table.draw();   
            }
            else {
                $('#janDataList_filter').show();
-               $('.container-inline-date').hide();
+               $('#block-bi-janrain-data-filter-options .container-inline-date').hide();
                $('#edit-datestart-datepicker-popup-0').val('');    
                $('#edit-dateend-datepicker-popup-0').val('');
                table.draw();

But it gives me these errors:

git apply "bi_janrain_data\inline-class-change.patch"
bi_janrain_data/inline-class-change.patch:10: trailing whitespace.
                $('#block-bi-janrain-data-filter-options .container-inline-date').hide();
bi_janrain_data/inline-class-change.patch:16: trailing whitespace.
                                $('#block-bi-janrain-data-filter-options .container-inline-date').show();
bi_janrain_data/inline-class-change.patch:23: trailing whitespace.
                                $('#block-bi-janrain-data-filter-options .container-inline-date').hide();
bi_janrain_data/inline-class-change.patch:31: trailing whitespace.
                                $('#block-bi-janrain-data-filter-options .container-inline-date').hide();
error: <html><b>Current File</b></html>: No such file or directory

I've tried this also:

git apply -p1  "bi_janrain_data\js\bi_janrain_data.js" "bi_janrain_data\inline-class-change.patch"
error: unrecognized input

Solution

  • Modify the patch file header. In its current state, git has no idea which file to apply to.
    Before:

    --- a/<html>bi_janrain_data.js (<b>Dec 28, 2017 12:15:26 PM</b>)</html>  
    +++ b/<html><b>Current File</b></html>
    

    After:

    --- a/bi_janrain_data/js/bi_janrain_data.js
    +++ b/bi_janrain_data/js/bi_janrain_data.js