aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java2
5 files changed, 31 insertions, 18 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
index f12c94b33e..1cf2fe669c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
@@ -171,17 +171,18 @@ public class CommitCommand extends GitCommand<RevCommit> {
Result rc = ru.update();
switch (rc) {
case NEW:
- case FAST_FORWARD:
+ case FAST_FORWARD: {
setCallable(false);
- if (state == RepositoryState.MERGING_RESOLVED) {
+ File meta = repo.getDirectory();
+ if (state == RepositoryState.MERGING_RESOLVED
+ && meta != null) {
// Commit was successful. Now delete the files
// used for merge commits
- new File(repo.getDirectory(), Constants.MERGE_HEAD)
- .delete();
- new File(repo.getDirectory(), Constants.MERGE_MSG)
- .delete();
+ new File(meta, Constants.MERGE_HEAD).delete();
+ new File(meta, Constants.MERGE_MSG).delete();
}
return revCommit;
+ }
case REJECTED:
case LOCK_FAILURE:
throw new ConcurrentRefUpdateException(
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index 2d99f65879..6b91481d3e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -165,9 +165,7 @@ public abstract class Repository {
*/
public abstract void create(boolean bare) throws IOException;
- /**
- * @return GIT_DIR
- */
+ /** @return local metadata directory; null if repository isn't local. */
public File getDirectory() {
return gitDir;
}
@@ -712,7 +710,13 @@ public abstract class Repository {
public abstract void openPack(File pack, File idx) throws IOException;
public String toString() {
- return "Repository[" + getDirectory() + "]";
+ String desc;
+ if (getDirectory() != null)
+ desc = getDirectory().getPath();
+ else
+ desc = getClass().getSimpleName() + "-"
+ + System.identityHashCode(this);
+ return "Repository[" + desc + "]";
}
/**
@@ -908,7 +912,7 @@ public abstract class Repository {
* @return an important state
*/
public RepositoryState getRepositoryState() {
- if (isBare())
+ if (isBare() || getDirectory() == null)
return RepositoryState.BARE;
// Pre Git-1.6 logic
@@ -1096,7 +1100,7 @@ public abstract class Repository {
* if the repository is "bare"
*/
public String readMergeCommitMsg() throws IOException {
- if (isBare())
+ if (isBare() || getDirectory() == null)
throw new IllegalStateException(
JGitText.get().bareRepositoryNoWorkdirAndIndex);
@@ -1123,7 +1127,7 @@ public abstract class Repository {
* if the repository is "bare"
*/
public List<ObjectId> readMergeHeads() throws IOException {
- if (isBare())
+ if (isBare() || getDirectory() == null)
throw new IllegalStateException(
JGitText.get().bareRepositoryNoWorkdirAndIndex);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
index 2bea8fecf1..39d734a32b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
@@ -120,7 +120,10 @@ public class RepositoryCache {
* repository to register.
*/
public static void register(final Repository db) {
- cache.registerRepository(FileKey.exact(db.getDirectory(), db.getFS()), db);
+ if (db.getDirectory() != null) {
+ FileKey key = FileKey.exact(db.getDirectory(), db.getFS());
+ cache.registerRepository(key, db);
+ }
}
/**
@@ -133,7 +136,10 @@ public class RepositoryCache {
* repository to unregister.
*/
public static void close(final Repository db) {
- cache.unregisterRepository(FileKey.exact(db.getDirectory(), db.getFS()));
+ if (db.getDirectory() != null) {
+ FileKey key = FileKey.exact(db.getDirectory(), db.getFS());
+ cache.unregisterRepository(key);
+ }
}
/** Unregister all repositories from the cache. */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
index fc203f69c8..27505bef65 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
@@ -271,8 +271,10 @@ class FetchProcess {
}
private void updateFETCH_HEAD(final FetchResult result) throws IOException {
- final LockFile lock = new LockFile(new File(transport.local
- .getDirectory(), "FETCH_HEAD"));
+ File meta = transport.local.getDirectory();
+ if (meta == null)
+ return;
+ final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD"));
try {
if (lock.lock()) {
final Writer w = new OutputStreamWriter(lock.getOutputStream());
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java
index 1b17c9f0f4..37e03fd62a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java
@@ -357,6 +357,6 @@ public class RemoteRefUpdate {
+ "..." + (newObjectId != null ? newObjectId.abbreviate(localDb).name() : "(null)")
+ (fastForward ? ", fastForward" : "")
+ ", srcRef=" + srcRef + (forceUpdate ? ", forceUpdate" : "") + ", message=" + (message != null ? "\""
- + message + "\"" : "null") + ", " + localDb.getDirectory() + "]";
+ + message + "\"" : "null") + "]";
}
}