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

Re: [PATCH] Create $GIT_DIR/objects/pack if missing during renameAndOpenPack

From
Shawn O. Pearce <spearce@spearce.org>
Date
May 10, 2009, 23:03 UTC
Message-ID
<20090510230341.GG30527@spearce.org>
In-Reply-To
<200905110059.50494.robin.rosenberg.lists@dewire.com>
Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
Show 12 quoted lines
> s?ndag 10 maj 2009 23:30:46 skrev "Shawn O. Pearce" <spearce@spearce.org>:
> > diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java
> > index b2bcbb7..1eb40d4 100644
> > --- a/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java
> > +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java
> > @@ -1037,6 +1037,14 @@ public PackLock renameAndOpenPack(final String lockMessage)
> >  		final File finalIdx = new File(packDir, "pack-" + name + ".idx");
> >  		final PackLock keep = new PackLock(finalPack);
> >  
> > +		if (!packDir.exists() && !packDir.mkdir() && !packDir.exists()) {
> 
> Is there a lot to gain by this instead of just if (!packDir.mkdir() && !packDir.exists()) ?

No, not really. But usually the directory exists, its rare when it doesn't.

We probably just wasted more CPU time in our MUAs debating this than it really costs in the long run. I'm too #@!** lazy to go back and amend this patch. But you can amend it if it really bothers you to do the "!exists && !mkdir && !exists".

-- 
Shawn.
Previous: Robin Rosenberg
Message 4 of 4 in “[JGIT] exception while pushing if no objects/pack directory exists in origin repo”
  1. Mark StrubergMay 9, 2009
  2. Create $GIT_DIR/objects/pack if missing during renameAndOpenPackShawn O. Pearce, May 10, 2009
  3. Robin RosenbergMay 10, 2009
  4. Shawn O. PearceMay 10, 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.