Permalink
Browse files

Issue 20: Change CheckoutBuilder.checkoutEntry to take blob ID and mode

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
  • Loading branch information...
1 parent 43f5a93 commit 6d6eba0e4be20f665ed4a5d544c64fd948c73a87 @jonas jonas committed Sep 19, 2009
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/org/nbgit/client/CheckoutBuilder.java
@@ -46,6 +46,7 @@
import java.util.Map;
import org.spearce.jgit.lib.FileMode;
import org.spearce.jgit.lib.GitIndex;
+import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.lib.Tree;
@@ -171,7 +172,7 @@ public void checkout() throws IOException {
File file = mapping.getValue();
if (backup)
backupFile(file);
- checkoutEntry(entry, file);
+ checkoutEntry(entry.getObjectId(), entry.getModeBits(), file);
}
}
@@ -191,19 +192,19 @@ private void backupFile(File file) throws IOException {
/*
* Code originally from GitIndex.
*/
- private void checkoutEntry(GitIndex.Entry e, File file) throws IOException {
+ private void checkoutEntry(ObjectId blobId, int modeBits, File file) throws IOException {
file.delete();
file.getParentFile().mkdirs();
FileChannel channel = new FileOutputStream(file).getChannel();
try {
- byte[] bytes = repository.openBlob(e.getObjectId()).getBytes();
+ byte[] bytes = repository.openBlob(blobId).getBytes();
ByteBuffer buffer = ByteBuffer.wrap(bytes);
if (channel.write(buffer) != bytes.length)
throw new IOException("Could not write file " + file);
} finally {
channel.close();
}
- setExecutable(file, FileMode.EXECUTABLE_FILE.equals(e.getModeBits()));
+ setExecutable(file, FileMode.EXECUTABLE_FILE.equals(modeBits));
}
}

0 comments on commit 6d6eba0

Please sign in to comment.