Browse Source

Fix timestamp in Zip archives

RevCommit.getCommitTime returns time in seconds since the epoch.
ZipArchiveEntry.setTime expects time in milliseconds.

Add the missing unit conversion to get the correct result.
Correct formatting to be consistent with the rest of the code.

Change-Id: I990b92f1d996ec8538d4857755694d91b142eb53
stable-4.7
Shawn Pearce 8 years ago
parent
commit
ff6e6c2214
  1. 6
      org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java

6
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java

@ -109,9 +109,9 @@ public final class ZipFormat extends BaseFormat implements
final ZipArchiveEntry entry = new ZipArchiveEntry(path);
if(tree instanceof RevCommit){
long commitTime = ((RevCommit) tree).getCommitTime();
entry.setTime(commitTime);
if (tree instanceof RevCommit) {
long t = ((RevCommit) tree).getCommitTime() * 1000L;
entry.setTime(t);
}
if (mode == FileMode.TREE) {

Loading…
Cancel
Save