Apply patch to specified file, completely ignoring the path/filename stored in the patch file?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4















I need to apply a patch to a file in a complicated directory and symlink scenario. No matter what I try, I can't figure out how to massage the patch arguments so that it would find the desired file. Is there a way to completely circumvent the problem and just EXPLICITLY TELL patch to which file it should apply the patch, ignoring the path/filename in the .patch file?










share|improve this question
























  • I'm not sure if there's a way to do with with patch options, but can you just edit the patch file instead?

    – Sparhawk
    Feb 1 at 8:46











  • Last resort. This is an automated build scenario where the patch is downloaded from the web, so I would have to either script the editing (cp, sed, patch, rm), or... patch the patch, which is silly.

    – Szczepan Hołyszewski
    Feb 1 at 9:04
















4















I need to apply a patch to a file in a complicated directory and symlink scenario. No matter what I try, I can't figure out how to massage the patch arguments so that it would find the desired file. Is there a way to completely circumvent the problem and just EXPLICITLY TELL patch to which file it should apply the patch, ignoring the path/filename in the .patch file?










share|improve this question
























  • I'm not sure if there's a way to do with with patch options, but can you just edit the patch file instead?

    – Sparhawk
    Feb 1 at 8:46











  • Last resort. This is an automated build scenario where the patch is downloaded from the web, so I would have to either script the editing (cp, sed, patch, rm), or... patch the patch, which is silly.

    – Szczepan Hołyszewski
    Feb 1 at 9:04














4












4








4








I need to apply a patch to a file in a complicated directory and symlink scenario. No matter what I try, I can't figure out how to massage the patch arguments so that it would find the desired file. Is there a way to completely circumvent the problem and just EXPLICITLY TELL patch to which file it should apply the patch, ignoring the path/filename in the .patch file?










share|improve this question
















I need to apply a patch to a file in a complicated directory and symlink scenario. No matter what I try, I can't figure out how to massage the patch arguments so that it would find the desired file. Is there a way to completely circumvent the problem and just EXPLICITLY TELL patch to which file it should apply the patch, ignoring the path/filename in the .patch file?







patch






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 1 at 9:14









Rui F Ribeiro

40.4k1479137




40.4k1479137










asked Feb 1 at 8:43









Szczepan HołyszewskiSzczepan Hołyszewski

1413




1413












  • I'm not sure if there's a way to do with with patch options, but can you just edit the patch file instead?

    – Sparhawk
    Feb 1 at 8:46











  • Last resort. This is an automated build scenario where the patch is downloaded from the web, so I would have to either script the editing (cp, sed, patch, rm), or... patch the patch, which is silly.

    – Szczepan Hołyszewski
    Feb 1 at 9:04


















  • I'm not sure if there's a way to do with with patch options, but can you just edit the patch file instead?

    – Sparhawk
    Feb 1 at 8:46











  • Last resort. This is an automated build scenario where the patch is downloaded from the web, so I would have to either script the editing (cp, sed, patch, rm), or... patch the patch, which is silly.

    – Szczepan Hołyszewski
    Feb 1 at 9:04

















I'm not sure if there's a way to do with with patch options, but can you just edit the patch file instead?

– Sparhawk
Feb 1 at 8:46





I'm not sure if there's a way to do with with patch options, but can you just edit the patch file instead?

– Sparhawk
Feb 1 at 8:46













Last resort. This is an automated build scenario where the patch is downloaded from the web, so I would have to either script the editing (cp, sed, patch, rm), or... patch the patch, which is silly.

– Szczepan Hołyszewski
Feb 1 at 9:04






Last resort. This is an automated build scenario where the patch is downloaded from the web, so I would have to either script the editing (cp, sed, patch, rm), or... patch the patch, which is silly.

– Szczepan Hołyszewski
Feb 1 at 9:04











2 Answers
2






active

oldest

votes


















9














If the patch only contains changes to a single file, you should be able to tell patch to apply those changes to a file of your choice by specifying it before the patch name:



patch myfile withthis.patch


will apply withthis.patch to myfile, ignoring the file name in the patch.



Quoting the man page:




The names of the files to be patched are usually taken from the patch file, but if there's just one file to be patched it can be specified on the command line as originalfile.







share|improve this answer






























    1














    If the patch applies to only one file you could simply, put a symlink in that location pointing at the file you want it to be applied to. (assuming that the reason you need it applied else-ware is because that file does not exist) Then just apply the patch.



    Even if it pointed at multiple files, it could be done this way, with more time.






    share|improve this answer






















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498089%2fapply-patch-to-specified-file-completely-ignoring-the-path-filename-stored-in-t%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      9














      If the patch only contains changes to a single file, you should be able to tell patch to apply those changes to a file of your choice by specifying it before the patch name:



      patch myfile withthis.patch


      will apply withthis.patch to myfile, ignoring the file name in the patch.



      Quoting the man page:




      The names of the files to be patched are usually taken from the patch file, but if there's just one file to be patched it can be specified on the command line as originalfile.







      share|improve this answer



























        9














        If the patch only contains changes to a single file, you should be able to tell patch to apply those changes to a file of your choice by specifying it before the patch name:



        patch myfile withthis.patch


        will apply withthis.patch to myfile, ignoring the file name in the patch.



        Quoting the man page:




        The names of the files to be patched are usually taken from the patch file, but if there's just one file to be patched it can be specified on the command line as originalfile.







        share|improve this answer

























          9












          9








          9







          If the patch only contains changes to a single file, you should be able to tell patch to apply those changes to a file of your choice by specifying it before the patch name:



          patch myfile withthis.patch


          will apply withthis.patch to myfile, ignoring the file name in the patch.



          Quoting the man page:




          The names of the files to be patched are usually taken from the patch file, but if there's just one file to be patched it can be specified on the command line as originalfile.







          share|improve this answer













          If the patch only contains changes to a single file, you should be able to tell patch to apply those changes to a file of your choice by specifying it before the patch name:



          patch myfile withthis.patch


          will apply withthis.patch to myfile, ignoring the file name in the patch.



          Quoting the man page:




          The names of the files to be patched are usually taken from the patch file, but if there's just one file to be patched it can be specified on the command line as originalfile.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 1 at 9:26









          Stephen KittStephen Kitt

          173k24393468




          173k24393468























              1














              If the patch applies to only one file you could simply, put a symlink in that location pointing at the file you want it to be applied to. (assuming that the reason you need it applied else-ware is because that file does not exist) Then just apply the patch.



              Even if it pointed at multiple files, it could be done this way, with more time.






              share|improve this answer



























                1














                If the patch applies to only one file you could simply, put a symlink in that location pointing at the file you want it to be applied to. (assuming that the reason you need it applied else-ware is because that file does not exist) Then just apply the patch.



                Even if it pointed at multiple files, it could be done this way, with more time.






                share|improve this answer

























                  1












                  1








                  1







                  If the patch applies to only one file you could simply, put a symlink in that location pointing at the file you want it to be applied to. (assuming that the reason you need it applied else-ware is because that file does not exist) Then just apply the patch.



                  Even if it pointed at multiple files, it could be done this way, with more time.






                  share|improve this answer













                  If the patch applies to only one file you could simply, put a symlink in that location pointing at the file you want it to be applied to. (assuming that the reason you need it applied else-ware is because that file does not exist) Then just apply the patch.



                  Even if it pointed at multiple files, it could be done this way, with more time.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 1 at 12:27









                  Michael ProkopecMichael Prokopec

                  1,504218




                  1,504218



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498089%2fapply-patch-to-specified-file-completely-ignoring-the-path-filename-stored-in-t%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown






                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay