diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2013-12-20 13:35:59 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2013-12-27 12:22:47 +0100 |
commit | 2a50e7065c8696c76641668576c2e1a6428652fd (patch) | |
tree | 9d39a931949cdf7d404d0a6da1d1dd90bd328c42 /org.eclipse.jgit.pgm/src | |
parent | 80be72d2c1133ea30efab30d0c2db161ee83c1b6 (diff) | |
download | jgit-2a50e7065c8696c76641668576c2e1a6428652fd.tar.gz jgit-2a50e7065c8696c76641668576c2e1a6428652fd.zip |
[CLI] Add option --millis / -m to debug-show-dir-cache command
This is useful when comparing mtime displayed by
$ jgit debug-show-dir-cache -m
with mtime displayed by
$ git ls-files --debug
or
$ stat "%m"
Change-Id: Id133ebe6f6093a56a6a6645e1c5bb18752fb2fd0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java index 71af3d10ab..bb4f73d7d1 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java @@ -56,26 +56,35 @@ import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.TextBuiltin; +import org.kohsuke.args4j.Option; @Command(usage = "usage_ShowDirCache") class ShowDirCache extends TextBuiltin { + + @Option(name = "--millis", aliases = { "-m" }, usage = "usage_showTimeInMilliseconds") + private boolean millis = false; + @Override protected void run() throws Exception { final SimpleDateFormat fmt; - fmt = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss.SSS"); + fmt = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss.SSS"); //$NON-NLS-1$ final DirCache cache = db.readDirCache(); for (int i = 0; i < cache.getEntryCount(); i++) { final DirCacheEntry ent = cache.getEntry(i); final FileMode mode = FileMode.fromBits(ent.getRawMode()); final int len = ent.getLength(); - final Date mtime = new Date(ent.getLastModified()); + long lastModified = ent.getLastModified(); + final Date mtime = new Date(lastModified); final int stage = ent.getStage(); outw.print(mode); outw.format(" %6d", valueOf(len)); //$NON-NLS-1$ outw.print(' '); - outw.print(fmt.format(mtime)); + if (millis) + outw.print(lastModified); + else + outw.print(fmt.format(mtime)); outw.print(' '); outw.print(ent.getObjectId().name()); outw.print(' '); |