From 96b9bb4a598a0c923ec83738ac1d48dd46691600 Mon Sep 17 00:00:00 2001 From: Constantine Plotnikov Date: Wed, 28 Jan 2009 20:02:33 +0300 Subject: [PATCH] git4idea: encoding bugfix --- .../src/git4idea/merge/GitMergeProvider.java | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/plugins/git4idea/src/git4idea/merge/GitMergeProvider.java b/plugins/git4idea/src/git4idea/merge/GitMergeProvider.java index d401951958..54211c8829 100644 --- a/plugins/git4idea/src/git4idea/merge/GitMergeProvider.java +++ b/plugins/git4idea/src/git4idea/merge/GitMergeProvider.java @@ -36,6 +36,7 @@ import git4idea.i18n.GitBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -90,13 +91,20 @@ public class GitMergeProvider implements MergeProvider2 { VcsRunnable runnable = new VcsRunnable() { @SuppressWarnings({"ConstantConditions"}) public void run() throws VcsException { - GitContentRevision original = new GitContentRevision(path, new GitRevisionNumber(":" + ORIGINAL_REVNUM), myProject, file.getCharset()); + GitContentRevision original = + new GitContentRevision(path, new GitRevisionNumber(":" + ORIGINAL_REVNUM), myProject, file.getCharset()); GitContentRevision current = new GitContentRevision(path, new GitRevisionNumber(":" + YOURS_REVNUM), myProject, file.getCharset()); GitContentRevision last = new GitContentRevision(path, new GitRevisionNumber(":" + THEIRS_REVNUM), myProject, file.getCharset()); - mergeData.ORIGINAL = original.getContent().getBytes(); - mergeData.CURRENT = current.getContent().getBytes(); - mergeData.LAST = last.getContent().getBytes(); - mergeData.LAST_REVISION_NUMBER = new GitRevisionNumber(THEIRS_REVISION); + final String encoding = file.getCharset().name(); + try { + mergeData.ORIGINAL = original.getContent().getBytes(encoding); + mergeData.CURRENT = current.getContent().getBytes(encoding); + mergeData.LAST = last.getContent().getBytes(encoding); + mergeData.LAST_REVISION_NUMBER = new GitRevisionNumber(THEIRS_REVISION); + } + catch (UnsupportedEncodingException ex) { + throw new IllegalStateException("Unexpected encoding failure file ecoding does not exists: "+encoding, ex); + } } }; VcsUtil.runVcsProcessWithProgress(runnable, GitBundle.message("merge.load.files"), false, myProject); @@ -162,9 +170,13 @@ public class GitMergeProvider implements MergeProvider2 { * The conflict status */ enum Status { - /** the file was modified on the branch */ + /** + * the file was modified on the branch + */ MODIFIED, - /** the file was deleted on the branch */ + /** + * the file was deleted on the branch + */ DELETED, } } -- 2.11.4.GIT