Re: [PATCH] Avoid accessing a slow working copy during diffcore operations.
From: Junio C Hamano <hidden>
Date: 2016-08-11 19:49:57
"Shawn O. Pearce" [off-list ref] 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.
quoted hunk
@@ -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;