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

Re: [PATCH JGit 2/5] Create abstract method on ObjectDatabase for accessing the list of local pack files.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 21, 2009, 19:40 UTC
Message-ID
<20090921194035.GM14660@spearce.org>
In-Reply-To
<1253062116-13830-3-git-send-email-mr.gaffo@gmail.com>
mr.gaffo@gmail.com wrote:
Show 5 quoted lines
> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
> +	public void testListLocalPacksWhenThereIsAPack() throws Exception {
> +		createTestDir();
> +		File packsDir = new File(testDir, "pack");
> +		packsDir.mkdirs();

Why not allow the ObjectDirectory code to create the directory before copying the pack into it?

> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
> +	/**
> +	 * The list of Packs THIS repo contains

Don't you mean the list of packs this object database contains? An object database may not be a git repository. Though yes, the common case is that it is a repository.

> +	 * @return List<PackFile> of package names contained in this repo. 
> +	 * 		   Should be an empty list if there are none.
> +	 */
> +	public abstract List<PackFile> listLocalPacks();

I think you should define this to be an unmodifiable list, not just any list. Its sad that the Java type system didn't support this idea back when they added the new collections APIs.

Show 5 quoted lines
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
> +	@Override
> +	public List<PackFile> listLocalPacks() {
> +		tryAgain1();
> +		return new ArrayList<PackFile>(Arrays.asList(packList.get().packs));

Instead of copying, why not return an unmodifiableList wrapped around the array? PackList will never modify its internal array.

-- 
Shawn.
Previous: Shawn O. PearceNext: Michael Gaffney
Message 10 of 12 in “Adding update-server-info functionality try2”
  1. Adding update-server-info functionality try2mr.gaffo@gmail.com, Sep 16, 2009
  2. 1/5 adding tests for ObjectDirectorymr.gaffo@gmail.com, Sep 16, 2009
  3. 2/5 Create abstract method on ObjectDatabase for accessing the list of local pack files.mr.gaffo@gmail.com, Sep 16, 2009
  4. 3/5 Implemented directory based info cache for objects/info/packs.mr.gaffo@gmail.com, Sep 16, 2009
  5. 4/5 Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory.mr.gaffo@gmail.com, Sep 16, 2009
  6. 5/5 added tests for the file based info cache update and made passmr.gaffo@gmail.com, Sep 16, 2009
  7. Shawn O. PearceOct 8, 2009
  8. Shawn O. PearceOct 8, 2009
  9. Shawn O. PearceOct 8, 2009
  10. Shawn O. PearceSep 21, 2009
  11. Michael GaffneySep 21, 2009
  12. Shawn O. PearceSep 21, 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.