aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2017-06-08 09:03:25 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2017-06-08 09:03:25 +0900
commit39ea39e8179b69907fff5686aefee084e72dde7d (patch)
treeb544f87e0ce6b876abf5beef34286de0ca2ab79a
parent94c06009aafc7a61ae8a55699851a3e3ed27c19c (diff)
parent1d1429697595040c3321e7c5406329b7e8fff48c (diff)
downloadjgit-39ea39e8179b69907fff5686aefee084e72dde7d.tar.gz
jgit-39ea39e8179b69907fff5686aefee084e72dde7d.zip
Merge branch 'stable-4.7' into stable-4.8
* stable-4.7: JGit v4.7.1.201706071930-r ArchiveCommand: Create prefix entry with commit time Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Change-Id: Id4df76da84fde253ce04484f3437816dc145b4f2
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java6
2 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
index 18c49ea286..6f32bfaa52 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
@@ -348,7 +348,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
commitBazAndFooSlashBar();
byte[] result = CLIGitCommand.executeRaw(
"git archive --prefix=x/ --format=zip master", db).outBytes();
- String[] expect = { "x/baz", "x/foo/", "x/foo/bar" };
+ String[] expect = { "x/", "x/baz", "x/foo/", "x/foo/bar" };
String[] actual = listZipEntries(result);
Arrays.sort(expect);
@@ -361,7 +361,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
commitBazAndFooSlashBar();
byte[] result = CLIGitCommand.executeRaw(
"git archive --prefix=x/ --format=tar master", db).outBytes();
- String[] expect = { "x/baz", "x/foo/", "x/foo/bar" };
+ String[] expect = { "x/", "x/baz", "x/foo/", "x/foo/bar" };
String[] actual = listTarEntries(result);
Arrays.sort(expect);
@@ -380,7 +380,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
commitFoo();
byte[] result = CLIGitCommand.executeRaw(
"git archive --prefix=x// --format=zip master", db).outBytes();
- String[] expect = { "x//foo" };
+ String[] expect = { "x/", "x//foo" };
assertArrayEquals(expect, listZipEntries(result));
}
@@ -389,7 +389,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
commitFoo();
byte[] result = CLIGitCommand.executeRaw(
"git archive --prefix=x// --format=tar master", db).outBytes();
- String[] expect = { "x//foo" };
+ String[] expect = { "x/", "x//foo" };
assertArrayEquals(expect, listTarEntries(result));
}
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);