git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [JGIT PATCH 4/5] Define Patch to parse a sequence of patch FileHeaders

From
Robin Rosenberg <robin.rosenberg.lists@dewire.com>
Date
Dec 11, 2008, 20:39 UTC
Message-ID
<200812112139.29875.robin.rosenberg.lists@dewire.com>
In-Reply-To
<20081211183954.GH32487@spearce.org>
torsdag 11 december 2008 19:39:54 skrev Shawn O. Pearce:
Show 8 quoted lines
> Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
> > > +		assertEquals(572, fRepositoryConfigTest.startOffset);
> > > +		assertEquals(1490, fRepositoryConfig.startOffset);
> >
> > 1487 here
> 
> Really?  1490 is the only value that the test vector passes with.
> What's the 3 bytes you think I'm off by?
...Quick, quick, find something else to pick on..  :->

Yes. Very little of the code in TemporaryBuffer is covered by the unit tests and number of conditionals in there are rather large. I tried messing with the constants in there to improve that and then PatchTest started to fail.

Here are the changes I tried with. I think it should still work with thes changes. Rather than changing the other tests, we might want to create a special test for only the buffer class.

-- robin
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java b/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java
index 27f6444..556ab71 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java
@@ -60,7 +60,7 @@
  * after this stream has been properly closed by {@link #close()}.
  */
 public class TemporaryBuffer extends OutputStream {
-       private static final int DEFAULT_IN_CORE_LIMIT = 1024 * 1024;
+       private static final int DEFAULT_IN_CORE_LIMIT = 1024;

        /** Chain of data, if we are still completely in-core; otherwise null. */
        private ArrayList<Block> blocks;
@@ -315,7 +315,7 @@ public void destroy() {
        }

        private static class Block {
-               static final int SZ = 8 * 1024;
+               static final int SZ = 512;

                final byte[] buffer = new byte[SZ];
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 11 of 15 in “Patch parsing API”
  1. 0/5 Patch parsing APIShawn O. Pearce, Dec 11, 2008
  2. 1/5 Add toByteArray() to TemporaryBufferShawn O. Pearce, Dec 11, 2008
  3. 2/5 Add copy(InputStream) to TemporaryBufferShawn O. Pearce, Dec 11, 2008
  4. 3/5 Define FileHeader to parse the header block of a git diffShawn O. Pearce, Dec 11, 2008
  5. 4/5 Define Patch to parse a sequence of patch FileHeadersShawn O. Pearce, Dec 11, 2008
  6. 5/5 Add HunkHeader to represent a single hunk of a file within a patchShawn O. Pearce, Dec 11, 2008
  7. Robin RosenbergDec 11, 2008
  8. Shawn O. PearceDec 11, 2008
  9. Robin RosenbergDec 11, 2008
  10. Shawn O. PearceDec 11, 2008
  11. Robin RosenbergDec 11, 2008
  12. Shawn O. PearceDec 11, 2008
  13. Robin RosenbergDec 11, 2008
  14. Shawn O. PearceDec 11, 2008
  15. 2/5 Add copy(InputStream) to TemporaryBufferShawn O. Pearce, Dec 11, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.