|
|
@ -17,6 +17,7 @@ import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.OutputStreamWriter; |
|
|
|
import java.io.OutputStreamWriter; |
|
|
|
import java.io.Writer; |
|
|
|
import java.io.Writer; |
|
|
|
|
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.StandardCopyOption; |
|
|
|
import java.nio.file.StandardCopyOption; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -34,7 +35,6 @@ import org.eclipse.jgit.patch.FileHeader; |
|
|
|
import org.eclipse.jgit.patch.HunkHeader; |
|
|
|
import org.eclipse.jgit.patch.HunkHeader; |
|
|
|
import org.eclipse.jgit.patch.Patch; |
|
|
|
import org.eclipse.jgit.patch.Patch; |
|
|
|
import org.eclipse.jgit.util.FileUtils; |
|
|
|
import org.eclipse.jgit.util.FileUtils; |
|
|
|
import org.eclipse.jgit.util.IO; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Apply a patch to files and/or to the index. |
|
|
|
* Apply a patch to files and/or to the index. |
|
|
@ -125,14 +125,9 @@ public class ApplyCommand extends GitCommand<ApplyResult> { |
|
|
|
break; |
|
|
|
break; |
|
|
|
case COPY: |
|
|
|
case COPY: |
|
|
|
f = getFile(fh.getOldPath(), false); |
|
|
|
f = getFile(fh.getOldPath(), false); |
|
|
|
byte[] bs = IO.readFully(f); |
|
|
|
File target = getFile(fh.getNewPath(), false); |
|
|
|
File target = getFile(fh.getNewPath(), true); |
|
|
|
FileUtils.mkdirs(target.getParentFile(), true); |
|
|
|
FileOutputStream fos = new FileOutputStream(target); |
|
|
|
Files.copy(f.toPath(), target.toPath()); |
|
|
|
try { |
|
|
|
|
|
|
|
fos.write(bs); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
fos.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
apply(target, fh); |
|
|
|
apply(target, fh); |
|
|
|
} |
|
|
|
} |
|
|
|
r.addUpdatedFile(f); |
|
|
|
r.addUpdatedFile(f); |
|
|
|