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
This commit is contained in:
commit
39ea39e817
|
@ -348,7 +348,7 @@ public void testArchivePrefixOption() throws Exception {
|
|||
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 void testTarPrefixOption() throws Exception {
|
|||
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 void testPrefixDoesNotNormalizeDoubleSlash() throws Exception {
|
|||
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 void testPrefixDoesNotNormalizeDoubleSlashInTar() throws Exception {
|
|||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -403,6 +403,12 @@ private <T extends Closeable> OutputStream writeArchive(Format<T> fmt) {
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue