From d7ee5aafee7c4eabeea6de8dd125a1ad4ddcdc0f Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 7 Aug 2019 23:28:32 +0200 Subject: [PATCH] reftable: increment pointer *after* reading uint16 This fixes timezone reads out of the reflog. Change-Id: I126d8742e5e904a074c544514180720466164f7c Signed-off-by: Han-Wen Nienhuys --- .../eclipse/jgit/internal/storage/reftable/ReftableTest.java | 2 ++ .../eclipse/jgit/internal/storage/reftable/BlockReader.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java index b67ec563f..0e33fa6e7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java @@ -624,6 +624,8 @@ public class ReftableTest { assertEquals(ObjectId.zeroId(), lc.getReflogEntry().getOldId()); assertEquals(id(1), lc.getReflogEntry().getNewId()); assertEquals(who, lc.getReflogEntry().getWho()); + // compare string too, to catch tz differences. + assertEquals(who.toExternalString(), lc.getReflogEntry().getWho().toExternalString()); assertEquals(msg, lc.getReflogEntry().getComment()); assertTrue(lc.next()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java index f9e184c99..b66751b94 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java @@ -557,7 +557,9 @@ class BlockReader { } private short readInt16() { - return (short) NB.decodeUInt16(buf, ptr += 2); + short result =(short) NB.decodeUInt16(buf, ptr); + ptr += 2; + return result; } private int readVarint32() {