Junio C Hamano wrote:
Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxx> writes:
Hmm, the subject line says "... increase array size ...", but that is not
necessarily what this patch is doing! :-D
True; will revert it out of 'next'.
Thanks for noticing.
Hi Junio and Ramsay,
In fact, i found lots of similar usage in the git source code. E.G.
in the dir.c,
int is_inside_dir(const char *dir)
{
char cwd[PATH_MAX];
if (!dir)
return 0;
if (!getcwd(cwd, sizeof(cwd)))
die_errno("can't find the current directory");
return dir_inside_of(cwd, dir) >= 0;
}
Since this implementation is not cross-OS safe, Could we use below solution?
step1, add a new function xgetcwd() to wrapper getcwd() like this:
char *xgetcwd(void)
{
size_t size = 100;
while (1) {
char *buffer = (char *) xmalloc (size);
if (getcwd (buffer, size) == buffer)
return buffer;
free (buffer);
if (errno != ERANGE)
return 0;
size *= 2;
}
}
step2, use xgetcwd to replace all getcwd occurrence in the git source code.
This will add a little bit overhead to the git, but it is cross-OS safe.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html