summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2013-12-27 08:55:39 -0800
committerJonathan Nieder <jrn@google.com>2013-12-27 08:55:39 -0800
commit2ecc27db9297e0dd9f4113699deeadd575731106 (patch)
treeb6e9cc336a072b0b7c129dcab87471402d00c035 /org.eclipse.jgit
parentf2abbd0ea99aed638ca098e336f60f52bc923237 (diff)
downloadjgit-2ecc27db9297e0dd9f4113699deeadd575731106.tar.gz
jgit-2ecc27db9297e0dd9f4113699deeadd575731106.zip
archive: Include entries for directories
Entries for directories are optional and mostly wasted space in most archive formats (except as a place to hang ownership and filesystem permissions), but "git archive" includes them. Follow suit. This will make it easier in a later change to include empty directories as placeholders for missing submodules. Change-Id: I1810c686bcc9eb4d73498e4d3e763e18787b088a Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
index c17330e6f1..2e6b50a6a5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
@@ -138,11 +138,13 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
* archive object from createArchiveOutputStream
* @param path
* full filename relative to the root of the archive
+ * (with trailing '/' for directories)
* @param mode
* mode (for example FileMode.REGULAR_FILE or
* FileMode.SYMLINK)
* @param loader
- * blob object with data for this entry
+ * blob object with data for this entry (null for
+ * directories)
* @throws IOException
* thrown by the underlying output stream for I/O errors
*/
@@ -275,16 +277,15 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
final RevWalk rw = new RevWalk(walk.getObjectReader());
walk.reset(rw.parseTree(tree));
- walk.setRecursive(true);
while (walk.next()) {
final String name = pfx + walk.getPathString();
final FileMode mode = walk.getFileMode(0);
- if (mode == FileMode.TREE)
- // ZIP entries for directories are optional.
- // Leave them out, mimicking "git archive".
+ if (walk.isSubtree()) {
+ fmt.putEntry(outa, name + "/", mode, null);
+ walk.enterSubtree();
continue;
-
+ }
walk.getObjectId(idBuf, 0);
fmt.putEntry(outa, name, mode, reader.open(idBuf));
}