aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2011-05-04 08:53:54 (EDT)
committerRobin Stocker2011-05-04 08:53:54 (EDT)
commit17cc1ec58b6c5fa514b5fbf9d912a9b30cff6558 (patch)
tree994d54cac0ca642ce2b7a75e1b695990bd882f2f
parent6a577c370b0881ebda0146ff07003b99bc4636ec (diff)
downloadegit-17cc1ec58b6c5fa514b5fbf9d912a9b30cff6558.zip
egit-17cc1ec58b6c5fa514b5fbf9d912a9b30cff6558.tar.gz
egit-17cc1ec58b6c5fa514b5fbf9d912a9b30cff6558.tar.bz2
Use workspace file encoding in commit dialog diffrefs/changes/30/3330/1
When viewing the diff (from the commit dialog) of a file that has a different encoding than the workspace encoding, it contains incorrect changes. One way to reproduce this problem: - Set the Eclipse workspace encoding to ISO-8859-1. - Create an XML file that has an explicit UTF-8 encoding set (either through an encoding attribute in the XML or as an explicit property on the resource). Add some non-ASCII characters in the file. - Commit it. - Change some unrelated lines in the file. - Open the commit dialog. - View the diff of the file. Before this change, the diff would show changes in the lines with non-ASCII characters, even though they didn't change. The reason is that the encoding of nextFile is correct because it is from the workspace. But it's wrong for baseFile because it's read as a blob from the repo, and the diff view therefore falls back to the wrong workspace encoding. After this change, the encoding from the IFile is also used to decode the previous file contents, and the diff is correct. Change-Id: I58ba71d30d7dd47068d2b212737896f6c1b9843a
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
index e236aff..fea25a5 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
@@ -226,8 +226,15 @@ public class CommitDialog extends Dialog {
IFileRevision baseFile = fileHistory.getFileRevisions()[0];
IFileRevision nextFile = fileHistoryProvider.getWorkspaceFileRevision(commitItem.file);
- ITypedElement base = new FileRevisionTypedElement(baseFile);
- ITypedElement next = new FileRevisionTypedElement(nextFile);
+ String encoding;
+ try {
+ encoding = commitItem.file.getCharset();
+ } catch (CoreException e1) {
+ encoding = null;
+ }
+
+ ITypedElement base = new FileRevisionTypedElement(baseFile, encoding);
+ ITypedElement next = new FileRevisionTypedElement(nextFile, encoding);
GitCompareFileRevisionEditorInput input = new GitCompareFileRevisionEditorInput(next, base, null);
CompareUI.openCompareDialog(input);