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

Re: [PATCH] Avoid accessing a slow working copy during diffcore operations.

From
Junio C Hamano <junkio@cox.net>
Date
Dec 16, 2006, 06:03 UTC
Message-ID
<7vpsakl6mu.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061214111557.GA24297@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
> If Git is compiled with NO_FAST_WORKING_DIRECTORY set then we will
> avoid looking at the working directory when the blob in question
> is available within a packfile and the caller doesn't need the data
> unpacked into a temporary file.
I'd take the patch as is, but...
> -static int work_tree_matches(const char *name, const unsigned char *sha1)
> +static int work_tree_matches(const char *name, const unsigned char *sha1, int want_file)

this feels wrong. It is not about "work tree matches" anymore. reuse_worktree_copy(), perhaps.

Show 18 quoted lines
> @@ -1193,6 +1193,20 @@ static int work_tree_matches(const char *name, const unsigned char *sha1)
>  	if (!active_cache)
>  		return 0;
>  
> +#ifdef NO_FAST_WORKING_DIRECTORY
> +	/* We want to avoid the working directory if our caller
> +	 * doesn't need the data in a normal file, this system
> +	 * is rather slow with its stat/open/mmap/close syscalls,
> +	 * and the object is contained in a pack file.  The pack
> +	 * is probably already open and will be faster to obtain
> +	 * the data through than the working directory.  Loose
> +	 * objects however would tend to be slower as they need
> +	 * to be individually opened and inflated.
> +	 */
> +	if (!want_file && has_sha1_pack(sha1, NULL))
> +		return 0;
> +#endif
> +
Also I'd prefer doing this without #ifdef;
        if (defined(NO_FAST_WORKING_DIRECTORY) &&
        	!want_file && has_sha1_pack(sha1, NULL))
		return 0;
Previous: Shawn PearceNext: Johannes Schindelin
Message 8 of 10 in “Avoid accessing a slow working copy during diffcore operations.”
  1. Avoid accessing a slow working copy during diffcore operations.Shawn O. Pearce, Dec 14, 2006
  2. Alex RiesenDec 14, 2006
  3. Johannes SchindelinDec 14, 2006
  4. Alex RiesenDec 14, 2006
  5. Johannes SchindelinDec 14, 2006
  6. Jakub NarebskiDec 15, 2006
  7. Shawn PearceDec 15, 2006
  8. Junio C HamanoDec 16, 2006
  9. Johannes SchindelinDec 16, 2006
  10. Junio C HamanoDec 16, 2006

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.