[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git
Subject:    Re: [PATCH] add GIT_FAST_STAT mode for Cygwin
From:       "Shawn O. Pearce" <spearce () spearce ! org>
Date:       2008-09-23 20:17:39
Message-ID: 20080923201739.GK3669 () spearce ! org
[Download RAW message or body]

Dmitry Potapov <dpotapov@gmail.com> wrote:
> Do I understand you correctly that you propose to add the code like
> this in compat/cygwin.c:

Yes.  But with minor changes (see below):
 
> static int native_stat;

static int native_stat = -1;

> static int git_cygwin_config(const char *var, const char *value, void
> *cb)
> {
> 	if (!strcmp(var, "core.cygwinnativestat"))
> 		cygwin_native_stat = git_config_bool(var, value);
> 	return 0;
> }
> 
> static void init_stat(void)
> {
> 	git_config(git_cygwin_config, NULL);
> 	cygwin_stat_fn = native_stat ? cygwin_stat : stat;
> 	cygwin_lstat_fn = native_stat ? cygwin_lstat : lstat;

if (native_stat < 0 && have_git_dir()) {
	native_stat = 0;
	git_config(git_cygwin_config, NULL);
	cygwin_stat_fn = native_stat ? cygwin_stat : stat;
	cygwin_lstat_fn = native_stat ? cygwin_lstat : lstat;
}

and then you have to define have_git_dir() inside environment.c as:

int have_git_dir(void)
{
	return !!git_dir;
}
 
> static int cygwin_stat_choice(const char *file_name, struct stat *buf)
> {
> 	init_stat();
> 	return (*cygwin_stat_fn)(file_name, buf);
> }
> 
> static int cygwin_lstat_choice(const char *file_name, struct stat *buf)
> {
> 	init_stat();
> 	return (*cygwin_lstat_fn)(file_name, buf);
> }

-- 
Shawn.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic