Grzenio
Grzenio

Reputation: 36649

How can I apply a TortoiseSVN generated patch to a git repository in Windows?

I was working on a project that was in subversion, but then it got migrated to git before I managed to commit the latest changes. I created a patch file using TortoiseSVN, but now I don't know how to apply it. I tried using git apply but it didn't work:

C:\Users\ga1009\Documents\quantlib>git apply ..\dev\Oasis\CatBond_QuantLib_wXL.p
atch
..\dev\Oasis\CatBond_QuantLib_wXL.patch:6: trailing whitespace.
/* This file is automatically generated; do not edit.     */
..\dev\Oasis\CatBond_QuantLib_wXL.patch:7: trailing whitespace.
/* Add the files to be included into Makefile.am instead. */
..\dev\Oasis\CatBond_QuantLib_wXL.patch:8: trailing whitespace.

..\dev\Oasis\CatBond_QuantLib_wXL.patch:9: trailing whitespace.
#include <ql/experimental/catbonds/catbond.hpp>
..\dev\Oasis\CatBond_QuantLib_wXL.patch:10: trailing whitespace.
#include <ql/experimental/catbonds/catrisk.hpp>
error: QuantLib_vc10.vcxproj: No such file or directory
error: QuantLib_vc10.vcxproj.filters: No such file or directory
error: test-suite/quantlibtestsuite.cpp: No such file or directory
error: test-suite/testsuite_vc10.vcxproj: No such file or directory
error: test-suite/testsuite_vc10.vcxproj.filters: No such file or directory
error: gensrc/config/categories.xml: No such file or directory
error: gensrc/metadata/types/types.xml: No such file or directory
error: QuantLibObjects_vc10.vcxproj: No such file or directory
error: QuantLibObjects_vc10.vcxproj.filters: No such file or directory
error: qlxl/QuantLibXLStatic_vc10.vcxproj: No such file or directory
error: qlxl/QuantLibXLStatic_vc10.vcxproj.filters: No such file or directory

These errors are a bit weird, because all of these files should be prefixed by another directory, e.g. from the patch file:

--- QuantLib/QuantLib_vc10.vcxproj  (revision 18468)
+++ QuantLib/QuantLib_vc10.vcxproj  (working copy)

I also tried using TortoiseMerge as suggested in https://stackoverflow.com/a/5415912/5363, but this tool complained about the target folder not being a repository (it is obviously not a svn repository)

EDIT: the patch.exe from gnuwin32 project complains about the same files. Is the patch file wrong in some way? The entry for the first file with errors is:

Index: QuantLib/QuantLib_vc10.vcxproj
===================================================================
--- QuantLib/QuantLib_vc10.vcxproj  (revision 18468)
+++ QuantLib/QuantLib_vc10.vcxproj  (working copy)
@@ -250,6 +250,11 @@
   <ItemGroup>
     <ClInclude Include="ql\cashflows\cpicoupon.hpp" />
     <ClInclude Include="ql\cashflows\cpicouponpricer.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\all.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\catbond.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\catrisk.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\montecarlocatbondengine.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\riskynotional.hpp" />
     <ClInclude Include="ql\experimental\finitedifferences\dynprogvppintrinsicvalueengine.hpp" />
     <ClInclude Include="ql\experimental\finitedifferences\fdextoujumpvanillaengine.hpp" />
     <ClInclude Include="ql\experimental\finitedifferences\fdklugeextouspreadengine.hpp" />
@@ -1375,6 +1380,10 @@
   <ItemGroup>
     <ClCompile Include="ql\cashflows\cpicoupon.cpp" />
     <ClCompile Include="ql\cashflows\cpicouponpricer.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\catbond.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\catrisk.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\montecarlocatbondengine.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\riskynotional.cpp" />
     <ClCompile Include="ql\experimental\finitedifferences\dynprogvppintrinsicvalueengine.cpp" />
     <ClCompile Include="ql\experimental\finitedifferences\fdextoujumpvanillaengine.cpp" />
     <ClCompile Include="ql\experimental\finitedifferences\fdklugeextouspreadengine.cpp" />

Upvotes: 2

Views: 1776

Answers (1)

robrich
robrich

Reputation: 13205

You could try using git-svn to re-convert your svn repository to git. Once it's in git, you could add a remote to your existing repository, and cherry-pick the commit in question from the "forgot to commit it" branch onto the regular branch. Then just push.

Alternatively, go really low-tech and just use a diff/merge tool to copy the file changes from one folder to the other.

Upvotes: 1

Related Questions