Skip to contentSkip to conversation

EGIT unpackedreadr problem

PATCH Robin Rosenberg 2 participants 2 messages Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

Subject: [PATCH] Utility to show a log.

This program shows commit information for a commit.

---

The main reason for this patch is not the program itself. The new code to read really fast but doesn't always work.

Try the supplied program. I get no parents and the treeid
is wrong. An interesting thing is that if you look in the debugger the author and commit messag is actually correct. Only the tree id and parent are wrong. Not sure what's going on. The UnpackedReader "looks" like it does the equivalent of what it did before,but apparently it isn't.

Reading commits from packs works fine. It's the unpacked reader that's bad.

-- robin

# java -Xmx100m -cp /home/me/SW/EGIT/org.spearce.jgit/bin org.spearce.jgit.pgm.Log c1ad80df56ff5f9d945eac8ac905b8009de30081
commit c1ad80df56ff5f9d945eac8ac905b8009de30081
tree 7ba4b782c23bb35b0cb7dbc46cfc09a6e887e19d
author PersonIdent[Shawn O. Pearce, [email protected], Wed Nov 29 21:02:45 CET 2006]

Misc. code formatting cleanups.

# git cat-file -p c1ad80df56ff5f9d945eac8ac905b8009de30081
tree a7ba4b7f1824763f182b6d45288e52fceece3c65b
parent 82c23bb35b0cb7dbc46cfc09a6e887e19dfb20f9
author Shawn O. Pearce <[email protected]> 1164830576 -0500
committer Shawn O. Pearce <[email protected]> 1164830576 -0500

Misc. code formatting cleanups.
[...]

 org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java |   23 ++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java new file +23 -0
new file mode 100644
index 0000000..9598792
@@ -0,0 +1,23 @@
+    package org.spearce.jgit.pgm;
+    
+    import java.io.File;
+    import java.io.IOException;
+import java.util.Iterator;
+
+import org.spearce.jgit.lib.Commit;
+import org.spearce.jgit.lib.Repository;
+    
+    public class Log {
+        public static void main(String[] args) throws IOException {
+            Repository db = new Repository(new File(".git"));	
+            Commit commit = db.mapCommit(args[0]);
+            System.out.println("commit "+commit.getCommitId());
+            System.out.println("tree "+commit.getTreeId());
+            for (Iterator ci=commit.getParentIds().iterator(); ci.hasNext(); ) {
+                System.out.println("parent "+ci.next());
+            }
+            System.out.println("author "+commit.getAuthor());
+            System.out.println();
+            System.out.println(commit.getMessage());
+        }
+    }
Signature · 1 line
1.4.4.gf05d
#1 lore raw
Quoted 1 line · Robin Rosenberg

Subject: [PATCH] Utility to show a log.

Thanks. This is somewhat handy so I've applied the utility program.

Like your other patch to Commit class this one had some whitespace issues. In the future could you apply the Eclipse formatter (using the Java Conventions style) to the source before genererating a diff?

Quoted 2 lines

Not sure what's going on. The UnpackedReader "looks" like it does the equivalent of what it did before,but apparently it isn't.

Yea... I broke the legacy header parsing in 42691339. The breakage actually showed up in one of the unit tests (test009_CreateCommitOldFormat) but I didn't notice it before pushing the changes out as I failed to run the entire unit test suite first. Whoops.

I found it and fixed it in f70704f9. The issue was we were copying the remaining data from the Inflater ontop of the data we had already decompressed out for the header; this meant that we lost the leading bytes of each object. I just neglated to push the fix out. Double whoops.