Daniel Barkalow <barkalow@iabervon.org> writes:
quoted text > diff --git a/path.c b/path.c
> index b7c24a2..790d8d4 100644
> --- a/path.c
> +++ b/path.c
> @@ -294,6 +294,23 @@ int adjust_shared_perm(const char *path)
> /* We allow "recursive" symbolic links. Only within reason, though. */
> #define MAXDEPTH 5
>
> +const char *make_relative_path(const char *abs, const char *base)
> +{
> + static char buf[PATH_MAX + 1];
> + int baselen;
> + if (!base)
> + return abs;
This special case may help the specific caller you have below, but doesn't
it make the function do more than it advertises with its name?
Other than that, I think the change is Ok, but as a "performance tweak",
it should be backed by some numbers, please?
quoted text > + baselen = strlen(base);
> + if (prefixcmp(abs, base))
> + return abs;
> + if (abs[baselen] == '/')
> + baselen++;
> + else if (base[baselen - 1] != '/')
> + return abs;
> + strcpy(buf, abs + baselen);
> + return buf;
> +}
> +
> const char *make_absolute_path(const char *path)
> {
> static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
> diff --git a/setup.c b/setup.c
> index d630e37..1643ee4 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -292,7 +292,8 @@ void setup_work_tree(void)
> work_tree = get_git_work_tree();
> git_dir = get_git_dir();
> if (!is_absolute_path(git_dir))
> - set_git_dir(make_absolute_path(git_dir));
> + set_git_dir(make_relative_path(make_absolute_path(git_dir),
> + work_tree));
> if (!work_tree || chdir(work_tree))
> die("This operation must be run in a work tree");
> initialized = 1;
> --
> 1.5.4.5
--
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