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

[JGIT PATCH 3/3] Use keep(1) instead of add() when skipping an entry

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 11, 2009, 19:58 UTC
Message-ID
<1252699129-6961-3-git-send-email-spearce@spearce.org>
In-Reply-To
<1252699129-6961-2-git-send-email-spearce@spearce.org>

Doing a keep call with a length of 1 will copy the current entry just like the previous add was doing, but it avoids doing any validation on the entry. This is sane because the entry can be assumed to be already valid, since its originating from the destination index.

Signed-off-by: Shawn O. Pearce <sop@google.com>
---
 .../jgit/dircache/DirCacheBuildIterator.java       |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuildIterator.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuildIterator.java
index 9818b76..94fc071 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuildIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuildIterator.java
@@ -111,7 +111,7 @@ public void skip() throws CorruptObjectException {
 		if (currentSubtree != null)
 			builder.keep(ptr, currentSubtree.getEntrySpan());
 		else
-			builder.add(currentEntry);
+			builder.keep(ptr, 1);
 		next(1);
 	}
 
-- 
1.6.5.rc0.164.g5f6b0
Previous: Shawn O. PearceNext: Halstrick, Christian
Message 3 of 4 in “Disallow creating invalid DirCacheEntry records”
  1. 1/3 Disallow creating invalid DirCacheEntry recordsShawn O. Pearce, Sep 11, 2009
  2. 2/3 Don't allow DirCacheEntry with mode of 0Shawn O. Pearce, Sep 11, 2009
  3. 3/3 Use keep(1) instead of add() when skipping an entryShawn O. Pearce, Sep 11, 2009
  4. git-svn and rebasing refactored (moved) contentHalstrick, Christian, Sep 15, 2009

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.