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

[JGIT PATCH 1/5] Expose RawParseUtils.match to application callers

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 1, 2008, 01:31 UTC
Message-ID
<1222824690-7632-2-git-send-email-spearce@spearce.org>
In-Reply-To
<1222824690-7632-1-git-send-email-spearce@spearce.org>

This utility can be useful when parsing a buffer directly, such as for a commit or tag object's header lines.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/util/RawParseUtils.java   |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
index dbc2e83..2ab3bfe 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
@@ -61,7 +61,18 @@
 			digits[i] = (byte) (i - '0');
 	}
 
-	private static final int match(final byte[] b, int ptr, final byte[] src) {
+	/**
+	 * Determine if b[ptr] matches src.
+	 * 
+	 * @param b
+	 *            the buffer to scan.
+	 * @param ptr
+	 *            first position within b, this should match src[0].
+	 * @param src
+	 *            the buffer to test for equality with b.
+	 * @return ptr += src.length if b[ptr..src.length] == src; else -1.
+	 */
+	public static final int match(final byte[] b, int ptr, final byte[] src) {
 		if (ptr + src.length >= b.length)
 			return -1;
 		for (int i = 0; i < src.length; i++, ptr++)
-- 
1.6.0.2.569.g798a2a
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 2 of 11 in “Support receive.fsckobjects”
  1. 0/5 Support receive.fsckobjectsShawn O. Pearce, Oct 1, 2008
  2. 1/5 Expose RawParseUtils.match to application callersShawn O. Pearce, Oct 1, 2008
  3. 2/5 Fix UnpackedObjectLoader.getBytes to return a copyShawn O. Pearce, Oct 1, 2008
  4. 3/5 Object validation tests for "jgit fsck"Shawn O. Pearce, Oct 1, 2008
  5. 4/5 Expose the critical receive configuration options to JGitShawn O. Pearce, Oct 1, 2008
  6. 5/5 Honor receive.fsckobjects during any fetch connectionShawn O. Pearce, Oct 1, 2008
  7. Robin RosenbergOct 1, 2008
  8. Shawn O. PearceOct 2, 2008
  9. Jonas FonsecaOct 9, 2008
  10. Shawn O. PearceOct 9, 2008
  11. Fix ObjectLoader.getBytes to really return the created copyJonas Fonseca, Oct 9, 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.