summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2011-09-04 16:34:15 +0200
committerRobin Rosenberg <robin.rosenberg@dewire.com>2011-09-08 16:46:20 +0200
commita7d3c680151aa27608c6381db0983b51828c2358 (patch)
tree22baf915d7cf7d53fc07933264b23540f2b9dbb6 /org.eclipse.jgit
parent576abf64d138606814e4b67c8110c4ee1ae1b2ac (diff)
downloadjgit-a7d3c680151aa27608c6381db0983b51828c2358.tar.gz
jgit-a7d3c680151aa27608c6381db0983b51828c2358.zip
Allow commit when submodule changes are present
We do not yet check or validate submodules, but can accept that someone staged a change in a submodule with other tools. Change-Id: I642ede382314bfbd1892dd509a2222885cc5350a Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java30
1 files changed, 19 insertions, 11 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 2412e2c6c0..d794c797b4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
@@ -66,6 +66,7 @@ import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.errors.UnmergedPathException;
import org.eclipse.jgit.lib.CommitBuilder;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.PersonIdent;
@@ -341,17 +342,24 @@ public class CommitCommand extends GitCommand<RevCommit> {
if (objectExists) {
dcEntry.setObjectId(fTree.getEntryObjectId());
} else {
- // insert object
- if (inserter == null)
- inserter = repo.newObjectInserter();
-
- InputStream inputStream = fTree.openEntryStream();
- try {
- dcEntry.setObjectId(inserter.insert(
- Constants.OBJ_BLOB, entryLength,
- inputStream));
- } finally {
- inputStream.close();
+ if (FileMode.GITLINK.equals(dcEntry.getFileMode())) {
+ // Do not check the content of submodule entries
+ // Use the old entry information instead.
+ dcEntry.copyMetaData(index.getEntry(dcEntry
+ .getPathString()));
+ } else {
+ // insert object
+ if (inserter == null)
+ inserter = repo.newObjectInserter();
+
+ InputStream inputStream = fTree.openEntryStream();
+ try {
+ dcEntry.setObjectId(inserter.insert(
+ Constants.OBJ_BLOB, entryLength,
+ inputStream));
+ } finally {
+ inputStream.close();
+ }
}
}