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

[JGIT PATCH 0/3] Introduce AbbreviatedObjectId

From
Shawn O. Pearce <spearce@spearce.org>
Date
Dec 10, 2008, 23:18 UTC
Message-ID
<1228951107-5546-1-git-send-email-spearce@spearce.org>

I'm using this new type to handle the "index" line of a git patch file, where object ids are generally shorter than 40 characters and thus aren't parsable by ObjectId.

Reading the short id is important because we can validate that a patch applies correctly by computing the SHA-1 of the result and testing it against the abbreviated id read in the "index" line. If the base object SHA-1 matches the abbreviated line then the result of applying the patch must also match; if it doesn't the patch application logic is broken.

Shawn O. Pearce (3):
  Define an abstraction for handling abbreviated SHA-1 strings
  Add ObjectId.startsWith(AbbreviatedObjectId)
  Change AnyObjectId.abbreviate() to return AbbreviatedObjectId
 .../ui/internal/components/RefContentProposal.java |    2 +-
 .../egit/ui/internal/fetch/FetchResultTable.java   |   12 +-
 .../egit/ui/internal/push/PushResultTable.java     |   21 +-
 .../src/org/spearce/jgit/pgm/Branch.java           |    2 +-
 .../src/org/spearce/jgit/pgm/Fetch.java            |    8 +-
 .../src/org/spearce/jgit/pgm/Push.java             |    5 +-
 .../spearce/jgit/lib/AbbreviatedObjectIdTest.java  |  285 ++++++++++++++++++++
 .../org/spearce/jgit/lib/AbbreviatedObjectId.java  |  262 ++++++++++++++++++
 .../src/org/spearce/jgit/lib/AnyObjectId.java      |   39 +++-
 9 files changed, 608 insertions(+), 28 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/AbbreviatedObjectIdTest.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/AbbreviatedObjectId.java
Next: Shawn O. Pearce
Message 1 of 4 in “Introduce AbbreviatedObjectId”
  1. 0/3 Introduce AbbreviatedObjectIdShawn O. Pearce, Dec 10, 2008
  2. 1/3 Define an abstraction for handling abbreviated SHA-1 stringsShawn O. Pearce, Dec 10, 2008
  3. 2/3 Add ObjectId.startsWith(AbbreviatedObjectId)Shawn O. Pearce, Dec 10, 2008
  4. 3/3 Change AnyObjectId.abbreviate() to return AbbreviatedObjectIdShawn O. Pearce, Dec 10, 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.