[EGIT PATCH 0/5] Support linked resources in repositories

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[EGIT PATCH 0/5] Support linked resources in repositories

Shawn Pearce
Sometimes users need to create links inside of a project to point
back to their Git working directory.  This is sort of like a symlink
in POSIX, but its managed at the Eclipse workspace level.

If a resource is contained within a linked directory and that is
also within a Git repository we want to allow Git operations on
that linked resource to operate using the paths of the files as
they are in the repository working directory, and not the path of
the files in the Eclipse workspace.

Shawn O. Pearce (5):
  Remove the pointless GitProjectData resource change listener
  Don't crash the decorator update loop when resources are deleted
  Fix RepositoryMapping.getRepoRelativePath to honor linked resources
  Change GitProjectData.getRepositoryMapping to work on linked
    resources
  Correct getRepositoryMapping callers to use any IResource

 .../egit/core/op/ConnectProviderOperation.java     |   14 +---
 .../org/spearce/egit/core/op/UntrackOperation.java |    4 +-
 .../spearce/egit/core/project/GitProjectData.java  |  111 ++++++--------------
 .../egit/core/project/RepositoryFinder.java        |   11 +--
 .../egit/core/project/RepositoryMapping.java       |   79 ++++++--------
 .../egit/ui/internal/actions/CommitAction.java     |    2 +-
 .../internal/decorators/GitResourceDecorator.java  |   11 ++-
 7 files changed, 81 insertions(+), 151 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[EGIT PATCH 1/5] Remove the pointless GitProjectData resource change listener

Shawn Pearce
Apparently on any IResourceChangeEvent.POST_CHANGE we just burn some
CPU time and generate some garbage for the GC to clean out later.  I
cannot see a reason why this code is still here.  My memory says we
did this in the past to notify the resource decorator that it needs
to update, or we used it for our cache tree invalidation.

Since this code has no side effect other than to waste time we can
safely remove it, and cut our project down a little bit.

Signed-off-by: Shawn O. Pearce <[hidden email]>
---
 .../spearce/egit/core/project/GitProjectData.java  |   64 --------------------
 1 files changed, 0 insertions(+), 64 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
index 8754bd1..3d5424c 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
@@ -29,8 +29,6 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IResourceChangeEvent;
 import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.Preferences;
@@ -61,10 +59,6 @@ public class GitProjectData {
  @SuppressWarnings("synthetic-access")
  public void resourceChanged(final IResourceChangeEvent event) {
  switch (event.getType()) {
- case IResourceChangeEvent.POST_CHANGE:
- projectsChanged(event.getDelta().getAffectedChildren(
- IResourceDelta.CHANGED));
- break;
  case IResourceChangeEvent.PRE_CLOSE:
  uncache((IProject) event.getResource());
  break;
@@ -182,16 +176,6 @@ public class GitProjectData {
  Activator.trace("(GitProjectData) " + m);
  }
 
- private static void projectsChanged(final IResourceDelta[] projDeltas) {
- for (int k = 0; k < projDeltas.length; k++) {
- final IResource r = projDeltas[k].getResource();
- final GitProjectData d = get((IProject) r);
- if (d != null) {
- d.notifyChanged(projDeltas[k]);
- }
- }
- }
-
  private synchronized static void cache(final IProject p,
  final GitProjectData d) {
  projectDataCache.put(p, d);
@@ -380,54 +364,6 @@ public class GitProjectData {
  }
  }
 
- private void notifyChanged(final IResourceDelta projDelta) {
-// final Set affectedMappings = new HashSet();
- try {
- projDelta.accept(new IResourceDeltaVisitor() {
- public boolean visit(final IResourceDelta d)
- throws CoreException {
- final int f = d.getFlags();
- IResource res = d.getResource();
- IResource r = res;
- if ((f & IResourceDelta.CONTENT) != 0
- || (f & IResourceDelta.ENCODING) != 0
- || r instanceof IContainer) {
- String s = null;
- RepositoryMapping m = null;
-
- while (r != null) {
- m = getRepositoryMapping(r);
- if (m != null) {
- break;
- }
-
- if (s != null) {
- s = r.getName() + "/" + s;
- } else {
- s = r.getName();
- }
-
- r = r.getParent();
- }
-
- if (m == null) {
- return false;
- } else if (s == null) {
- return true;
- }
- }
- return false;
- }
- });
- } catch (CoreException ce) {
- // We are in deep trouble. This should NOT have happend. Detach
- // our listeners and forget it ever did.
- //
- detachFromWorkspace();
- Activator.logError(CoreText.GitProjectData_notifyChangedFailed, ce);
- }
- }
-
  private File propertyFile() {
  return new File(getProject()
  .getWorkingLocation(Activator.getPluginId()).toFile(),
--
1.6.0.rc1.250.g9b5e2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[EGIT PATCH 2/5] Don't crash the decorator update loop when resources are deleted

Shawn Pearce
If a resource is deleted from the workspace we don't need to clear
its GITFOLDERDIRTYSTATEPROPERTY from the item because it is gone.
There won't be anyone else to query for that flag, so the flag is
not relevant anymore.  Further trying to call accept() on those
resources throws an exception because Eclipse won't let you touch
a deleted resource.

Signed-off-by: Shawn O. Pearce <[hidden email]>
---
 .../internal/decorators/GitResourceDecorator.java  |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java
index 6d2f88e..84ad949 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java
@@ -126,6 +126,14 @@ public class GitResourceDecorator extends LabelProvider implements
  Iterator<IResource> i = resources.iterator();
  m = i.next();
  i.remove();
+
+ while (!m.isAccessible()) {
+ if (!i.hasNext())
+ return Status.OK_STATUS;
+ m = i.next();
+ i.remove();
+ }
+
  if (resources.size() > 0)
  schedule();
  }
@@ -188,8 +196,7 @@ public class GitResourceDecorator extends LabelProvider implements
  } // End ResCL
 
  void clearDecorationState(IResource r) throws CoreException {
- if (r.isAccessible())
- r.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, null);
+ r.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, null);
  fireLabelProviderChanged(new LabelProviderChangedEvent(this, r));
  }
 
--
1.6.0.rc1.250.g9b5e2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[EGIT PATCH 3/5] Fix RepositoryMapping.getRepoRelativePath to honor linked resources

Shawn Pearce
If a project resource is linked to a repository working directory we
should be locating the path of the resource within the repository by
the path it appears in the filesystem, not the path it appears at in
the Eclipse project structure.  By using the filesystem location we
can ensure the paths match what C Git would see when accessing the
same resource.

By making this change we can now safely remove the subset concept
from RepositoryMapping as it was a crude form of trying to come up
with the same result when projects appeared within a repository.

Signed-off-by: Shawn O. Pearce <[hidden email]>
---
 .../egit/core/op/ConnectProviderOperation.java     |   14 +----
 .../egit/core/project/RepositoryFinder.java        |   11 +--
 .../egit/core/project/RepositoryMapping.java       |   65 ++++++++-----------
 3 files changed, 32 insertions(+), 58 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/ConnectProviderOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/ConnectProviderOperation.java
index 3ed3569..bf814f4 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/ConnectProviderOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/ConnectProviderOperation.java
@@ -15,10 +15,8 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IWorkspaceRunnable;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.team.core.RepositoryProvider;
 import org.spearce.egit.core.Activator;
@@ -70,17 +68,7 @@ public class ConnectProviderOperation implements IWorkspaceRunnable {
 
  db = new Repository(newGitDir);
  db.create();
- IPath gitDirParent = Path.fromOSString(
- db.getDirectory().getAbsolutePath())
- .removeLastSegments(1);
- IPath cPath = project.getLocation();
- String subset = null;
- if (gitDirParent.isPrefixOf(cPath)) {
- int n = cPath.matchingFirstSegments(gitDirParent);
- subset = cPath.removeFirstSegments(n).toPortableString();
- }
- repos.add(new RepositoryMapping(project, db.getDirectory(),
- subset));
+ repos.add(new RepositoryMapping(project, db.getDirectory()));
  db.close();
 
  // If we don't refresh the project directory right
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java
index 68cf79c..116a7bf 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java
@@ -92,17 +92,15 @@ public class RepositoryFinder {
  final IResource[] children;
 
  if (ownCfg.isFile()) {
- register(c, ownCfg.getParentFile(), null);
+ register(c, ownCfg.getParentFile());
  } else if (c.isLinked() || c instanceof IProject) {
- String s = fsLoc.getName();
  File p = fsLoc.getParentFile();
  while (p != null) {
  final File pCfg = configFor(p);
  if (pCfg.isFile()) {
- register(c, pCfg.getParentFile(), s);
+ register(c, pCfg.getParentFile());
  break;
  }
- s = p.getName() + "/" + s;
  p = p.getParentFile();
  }
  }
@@ -132,14 +130,13 @@ public class RepositoryFinder {
  return new File(new File(fsLoc, ".git"), "config");
  }
 
- private void register(final IContainer c, final File gitdir,
- final String subset) {
+ private void register(final IContainer c, final File gitdir) {
  File f;
  try {
  f = gitdir.getCanonicalFile();
  } catch (IOException ioe) {
  f = gitdir.getAbsoluteFile();
  }
- results.add(new RepositoryMapping(c, f, subset));
+ results.add(new RepositoryMapping(c, f));
  }
 }
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
index 6a0b56f..17e8142 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
@@ -41,10 +41,10 @@ public class RepositoryMapping {
 
  private final String gitdirPath;
 
- private final String subset;
-
  private Repository db;
 
+ private String workdirPrefix;
+
  private IContainer container;
 
  /**
@@ -55,12 +55,9 @@ public class RepositoryMapping {
  */
  public RepositoryMapping(final Properties p, final String initialKey) {
  final int dot = initialKey.lastIndexOf('.');
- String s;
 
  containerPath = initialKey.substring(0, dot);
  gitdirPath = p.getProperty(initialKey);
- s = p.getProperty(containerPath + ".subset");
- subset = "".equals(s) ? null : s;
  }
 
  /**
@@ -69,10 +66,8 @@ public class RepositoryMapping {
  *
  * @param mappedContainer
  * @param gitDir
- * @param subsetRoot
  */
- public RepositoryMapping(final IContainer mappedContainer,
- final File gitDir, final String subsetRoot) {
+ public RepositoryMapping(final IContainer mappedContainer, final File gitDir) {
  final IPath cLoc = mappedContainer.getLocation()
  .removeTrailingSeparator();
  final IPath gLoc = Path.fromOSString(gitDir.getAbsolutePath())
@@ -98,8 +93,6 @@ public class RepositoryMapping {
  } else {
  gitdirPath = gLoc.toPortableString();
  }
-
- subset = "".equals(subsetRoot) ? null : subsetRoot;
  }
 
  IPath getContainerPath() {
@@ -111,17 +104,6 @@ public class RepositoryMapping {
  }
 
  /**
- * Eclipse projects typically reside one or more levels
- * below the repository. This method return the relative
- * path to the project. Null is returned instead of "".
- *
- * @return relative path from repository to project, or null
- */
- public String getSubset() {
- return subset;
- }
-
- /**
  * @return the workdir file, i.e. where the files are checked out
  */
  public File getWorkDir() {
@@ -130,6 +112,7 @@ public class RepositoryMapping {
 
  synchronized void clear() {
  db = null;
+ workdirPrefix = null;
  container = null;
  }
 
@@ -142,6 +125,15 @@ public class RepositoryMapping {
 
  synchronized void setRepository(final Repository r) {
  db = r;
+
+ try {
+ workdirPrefix = getWorkDir().getCanonicalPath();
+ } catch (IOException err) {
+ workdirPrefix = getWorkDir().getAbsolutePath();
+ }
+ workdirPrefix = workdirPrefix.replace('\\', '/');
+ if (!workdirPrefix.endsWith("/"))
+ workdirPrefix += "/";
  }
 
  /**
@@ -166,9 +158,6 @@ public class RepositoryMapping {
 
  synchronized void store(final Properties p) {
  p.setProperty(containerPath + ".gitdir", gitdirPath);
- if (subset != null && !"".equals(subset)) {
- p.setProperty(containerPath + ".subset", subset);
- }
  }
 
  public String toString() {
@@ -209,20 +198,20 @@ public class RepositoryMapping {
  * @param rsrc
  * @return the path relative to the Git repository, including base name.
  */
- public String getRepoRelativePath(IResource rsrc) {
- String prefix = getSubset();
- String projectRelativePath = rsrc.getProjectRelativePath().toString();
- String repoRelativePath;
- if (prefix != null) {
- if (projectRelativePath.length() == 0)
- repoRelativePath = prefix;
- else
- repoRelativePath = prefix + "/" + projectRelativePath;
- } else
- repoRelativePath = projectRelativePath;
-
- assert repoRelativePath != null;
- return repoRelativePath;
+ public String getRepoRelativePath(final IResource rsrc) {
+ // We should only be called for resources that are actually
+ // in this repository, so we can safely assume that their
+ // path prefix matches workdirPrefix. Testing that here is
+ // rather expensive so we don't bother.
+ //
+ final int pfxLen = workdirPrefix.length();
+ final String p = rsrc.getLocation().toString();
+ final int pLen = p.length();
+ if (pLen > pfxLen)
+ return p.substring(pfxLen);
+ else if (p.length() == pfxLen - 1)
+ return "";
+ return null;
  }
 
  /**
--
1.6.0.rc1.250.g9b5e2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[EGIT PATCH 4/5] Change GitProjectData.getRepositoryMapping to work on linked resources

Shawn Pearce
When we are looking up the mapping for a file contained within a linked
directory the linked directory may be mapped to a Git repository that is
not the same as the project itself, or the project doesn't even have a
Git repository.

This may also be necessary for submodules.  For example a single project
in Eclipse may actually contain several Git submodules below it and each
must have its own RepositoryMapping.

We now store the RepositoryMapping for a given IContainer directly on
that container using a session property.  This way Eclipse manages the
hash lookups for us, and we can efficiently walk up the tree to locate
the nearest mapping for any resource.

Signed-off-by: Shawn O. Pearce <[hidden email]>
---
 .../spearce/egit/core/project/GitProjectData.java  |   47 +++++++++++++-------
 1 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
index 3d5424c..9998880 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
@@ -32,6 +32,7 @@ import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.team.core.RepositoryProvider;
 import org.spearce.egit.core.Activator;
@@ -71,6 +72,9 @@ public class GitProjectData {
  }
  }
 
+ private static QualifiedName MAPPING_KEY = new QualifiedName(
+ GitProjectData.class.getName(), "RepositoryMapping");
+
  /**
  * Start listening for resource changes.
  *
@@ -226,8 +230,6 @@ public class GitProjectData {
 
  private final Collection mappings;
 
- private final Map c2mapping;
-
  private final Set protectedResources;
 
  /**
@@ -239,7 +241,6 @@ public class GitProjectData {
  public GitProjectData(final IProject p) {
  project = p;
  mappings = new ArrayList();
- c2mapping = new HashMap();
  protectedResources = new HashSet();
  }
 
@@ -267,15 +268,16 @@ public class GitProjectData {
  * @throws CoreException
  */
  public void markTeamPrivateResources() throws CoreException {
- final Iterator i = c2mapping.entrySet().iterator();
- while (i.hasNext()) {
- final Map.Entry e = (Map.Entry) i.next();
- final IContainer c = (IContainer) e.getKey();
+ for (final Object rmObj : mappings) {
+ final RepositoryMapping rm = (RepositoryMapping)rmObj;
+ final IContainer c = rm.getContainer();
+ if (c == null)
+ continue; // Not fully mapped yet?
+
  final IResource dotGit = c.findMember(".git");
  if (dotGit != null) {
  try {
- final Repository r = ((RepositoryMapping) e.getValue())
- .getRepository();
+ final Repository r = rm.getRepository();
  final File dotGitDir = dotGit.getLocation().toFile()
  .getCanonicalFile();
  if (dotGitDir.equals(r.getDirectory())) {
@@ -298,14 +300,23 @@ public class GitProjectData {
  }
 
  /**
- * TODO: check usage, we should probably declare the parameter
- * as IProject.
- *
- * @param r Eclipse project
+ * @param r any workbench resource contained within this project.
  * @return the mapping for the specified project
  */
- public RepositoryMapping getRepositoryMapping(final IResource r) {
- return (RepositoryMapping) c2mapping.get(r);
+ public RepositoryMapping getRepositoryMapping(IResource r) {
+ try {
+ while (r != null) {
+ final RepositoryMapping m;
+
+ m = (RepositoryMapping) r.getSessionProperty(MAPPING_KEY);
+ if (m != null)
+ return m;
+ r = r.getParent();
+ }
+ } catch (CoreException err) {
+ Activator.logError("Falied finding RepositoryMapping", err);
+ }
+ return null;
  }
 
  private void delete() {
@@ -445,7 +456,11 @@ public class GitProjectData {
  m.fireRepositoryChanged();
 
  trace("map " + c + " -> " + m.getRepository());
- c2mapping.put(c, m);
+ try {
+ c.setSessionProperty(MAPPING_KEY, m);
+ } catch (CoreException err) {
+ Activator.logError("Failed to cache RepositoryMapping", err);
+ }
 
  dotGit = c.findMember(".git");
  if (dotGit != null && dotGit.getLocation().toFile().equals(git)) {
--
1.6.0.rc1.250.g9b5e2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[EGIT PATCH 5/5] Correct getRepositoryMapping callers to use any IResource

Shawn Pearce
We really need to use the exact resource we want a mapping for, even
if that is an IFile, because the file may be in a different repository
than the project it is contained in.  This can happen due to linked
resources, or due to submodules.  Either way the mapping cannot be
driven by the project.

Signed-off-by: Shawn O. Pearce <[hidden email]>
---
 .../org/spearce/egit/core/op/UntrackOperation.java |    4 +---
 .../egit/core/project/RepositoryMapping.java       |   14 +++++++-------
 .../egit/ui/internal/actions/CommitAction.java     |    2 +-
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java
index 369ff38..b491e6d 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/UntrackOperation.java
@@ -15,7 +15,6 @@ import java.util.IdentityHashMap;
 import java.util.Iterator;
 
 import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IResourceVisitor;
 import org.eclipse.core.resources.IWorkspaceRunnable;
@@ -67,9 +66,8 @@ public class UntrackOperation implements IWorkspaceRunnable {
  obj = ((IAdaptable)obj).getAdapter(IResource.class);
  if (obj instanceof IResource) {
  final IResource toRemove = (IResource)obj;
- final IProject p = toRemove.getProject();
  final GitProjectData pd = GitProjectData.get(toRemove.getProject());
- final RepositoryMapping rm = pd.getRepositoryMapping(p);
+ final RepositoryMapping rm = pd.getRepositoryMapping(toRemove);
  final GitIndex index = rm.getRepository().getIndex();
  tomerge.put(rm, Boolean.TRUE);
  if (toRemove instanceof IContainer) {
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
index 17e8142..961dbaf 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
@@ -221,15 +221,15 @@ public class RepositoryMapping {
  * @return the RepositoryMapping for this resource,
  *         or null for non GitProvider.
  */
- public static RepositoryMapping getMapping(IResource resource) {
- IProject project = resource.getProject();
+ public static RepositoryMapping getMapping(final IResource resource) {
+ final IProject project = resource.getProject();
  if (project == null)
  return null;
- RepositoryProvider provider = RepositoryProvider.getProvider(project);
- if (!(provider instanceof GitProvider))
+
+ final RepositoryProvider rp = RepositoryProvider.getProvider(project);
+ if (!(rp instanceof GitProvider))
  return null;
- GitProvider gp = (GitProvider)provider;
- RepositoryMapping repositoryMapping = gp.getData().getRepositoryMapping(project);
- return repositoryMapping;
+
+ return ((GitProvider)rp).getData().getRepositoryMapping(resource);
  }
 }
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
index db38c10..4956be3 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
@@ -363,7 +363,7 @@ public class CommitAction extends RepositoryAction {
 
  try {
  RepositoryMapping repositoryMapping = projectData
- .getRepositoryMapping(resource.getProject());
+ .getRepositoryMapping(resource);
 
  if (isChanged(repositoryMapping, resource)) {
  files.add(resource);
--
1.6.0.rc1.250.g9b5e2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html