Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-03-02 17:27:14 +0000
committerMichael Keppler2019-05-01 05:22:52 +0000
commitb703ea7740bc91619f4b9fb00940ba83272df951 (patch)
tree97ad2ec3dd5a4227cc80b0dd0680a4852efafdc5
parentb83ddfeb998a88539f870cfb4785ff1d672b9ac5 (diff)
downloadegit-b703ea7740bc91619f4b9fb00940ba83272df951.tar.gz
egit-b703ea7740bc91619f4b9fb00940ba83272df951.tar.xz
egit-b703ea7740bc91619f4b9fb00940ba83272df951.zip
Shorten SHA1 in editor title
When opening a commit from history, it used the full SHA1 in the editor title, leading to very wide tabs. Use a short version instead. The shortening of the SHA1 was done in the editor input calculation instead of the getContentIdentifier() method to avoid side effects at other callers of getContentIdentifier(), which use that for equals() comparisons of revisions. Bug:544983 Change-Id: Ic15c12d0cd4827090d124de10765b76c62e1096e Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java11
2 files changed, 12 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
index 5a4c294cc4..f2a0d12ffa 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
@@ -406,7 +406,8 @@ public class HistoryViewTest extends LocalRepositoryTestCase {
.click();
// Editor for old file version should be opened
- bot.editorByTitle(FILE1 + " " + commit.getParent(0).getName());
+ bot.editorByTitle(
+ FILE1 + " " + commit.getParent(0).getName().substring(0, 7));
}
@Test
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
index ad5fe3ec33..f054fecd8f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
@@ -32,6 +32,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter;
import org.eclipse.egit.ui.internal.UIText;
@@ -202,9 +203,17 @@ public class FileRevisionEditorInput extends PlatformObject implements
public String getName() {
IFileRevision rev = AdapterUtils.adapt(this, IFileRevision.class);
if (rev != null) {
+ String identifier;
+ if (rev instanceof CommitFileRevision) {
+ // 7 characters as in Utils.getShortObjectId(), used in the
+ // window title
+ identifier = rev.getContentIdentifier().substring(0, 7);
+ } else {
+ identifier = rev.getContentIdentifier();
+ }
return MessageFormat.format(
UIText.FileRevisionEditorInput_NameAndRevisionTitle,
- rev.getName(), rev.getContentIdentifier());
+ rev.getName(), identifier);
}
IFileState state = AdapterUtils.adapt(this, IFileState.class);
if (state != null) {

Back to the top