Stefan Beller <[email protected]> writes:

> +     char *sm_gitdir_rel, *p, *path = NULL;
> +     const char *sm_gitdir;
>       struct strbuf rel_path = STRBUF_INIT;
>       struct strbuf sb = STRBUF_INIT;
>  
> @@ -198,7 +199,14 @@ static int module_clone(int argc, const char **argv, 
> const char *prefix)
>               die(_("submodule--helper: unspecified or empty --path"));
>  
>       strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
> -     sm_gitdir = strbuf_detach(&sb, NULL);
> +     sm_gitdir_rel = strbuf_detach(&sb, NULL);
> +     sm_gitdir = absolute_path(sm_gitdir_rel);

With this change, sm_gitdir will always be absolute, which means the
parameter to clone_submodule() call (immedately after this hunk)
will now be always absolute.  I do not think "git clone" called from
there will leave anything in the resulting repository that depends
on the --separate-git-dir=<dir> being relative or absolute, so this
change should not cause us new problems.

By the way, this line is the last use of sm_gitdir_rel before it
gets freed.  I wonder

        sm_gitdir = absolute_path(sb.buf);

would be sufficient.  We can lose the variable, and free() on it at
the end of this function, and an extra allocation if we can do so.

> +     if (!is_absolute_path(path)) {
> +             strbuf_addf(&sb, "%s/%s", get_git_work_tree(), path);
> +             path = strbuf_detach(&sb, 0);
> +     } else
> +             path = xstrdup(path);
>  
>       if (!file_exists(sm_gitdir)) {
>               if (safe_create_leading_directories_const(sm_gitdir) < 0)

Other than that, looks good to me.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to