summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorYasuhiro Takagi <ytakagi@bea.hi-ho.ne.jp>2017-04-29 20:35:10 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2017-06-05 19:35:46 -0400
commita66e60a98620c5ba9cd3d9fc8f97f268229589e6 (patch)
tree6ebd94aef1c6c634ad14a9bde84a20168c24a3c1 /org.eclipse.jgit
parent6b1e3c58b16651dc72ec79a614d507e014d18393 (diff)
downloadjgit-a66e60a98620c5ba9cd3d9fc8f97f268229589e6.tar.gz
jgit-a66e60a98620c5ba9cd3d9fc8f97f268229589e6.zip
ArchiveCommand: Create prefix entry with commit time
The cgit archive command creates a prefix (root) directory entry in the archive file. That entry's time is set to the commit time. This patch makes jgit's behavior consistent with with cgit: prefix: hoge/ -> creates prefix directory "hoge/" entry. prefix: hoge//// -> creates prefix directory "hoge/" entry. prefix: hoge/foo -> does not create prefix directory entry, but for each file/directory entry, prefix is added. Change-Id: I2610e40ce37972c5f7456fdca6337e7fb07176e5 Signed-off-by: Yasuhiro Takagi <ytakagi@bea.hi-ho.ne.jp>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java6
1 files changed, 6 insertions, 0 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 0d18eb3d07..7ea8e73b36 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java
@@ -403,6 +403,12 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
if (!paths.isEmpty())
walk.setFilter(PathFilterGroup.createFromStrings(paths));
+ // Put base directory into archive
+ if (pfx.endsWith("/")) { //$NON-NLS-1$
+ fmt.putEntry(outa, tree, pfx.replaceAll("[/]+$", "/"), //$NON-NLS-1$ //$NON-NLS-2$
+ FileMode.TREE, null);
+ }
+
while (walk.next()) {
String name = pfx + walk.getPathString();
FileMode mode = walk.getFileMode(0);